8000 Box and Whiskers plot doesn't show correctly the minimum value · Issue #1201 · omnetpp/omnetpp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Box and Whiskers plot doesn't show correctly the minimum value #1201

New issue

Have a question about this project? S 8000 ign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
marsluca opened this issue Sep 1, 2024 · 3 comments
Open

Box and Whiskers plot doesn't show correctly the minimum value #1201

marsluca opened this issue Sep 1, 2024 · 3 comments

Comments

@marsluca
Copy link
marsluca commented Sep 1, 2024

Platform

  • OMNeT++ version: 6.0.2
  • OS: Windows

Describe the bug
Even if the minimum value is zero, it looks like it's less from the graph. (See the orange candlestick)

image

To Reproduce
Printing any histogram using the box and whiskers plot.

Code: (box and whiskers plot default template)

import pandas as pd
from omnetpp.scave import results, chart, utils

props = chart.get_properties()
utils.preconfigure_plot(props)

try:
    stats = results.get_statistics(props["filter"], include_attrs=True, include_runattrs=True, include_itervars=True)
    hists = results.get_histograms(props["filter"], include_attrs=True, include_runattrs=True, include_itervars=True)
except results.ResultQueryError as e:
    raise chart.ChartScriptError("Error while querying results: " + str(e))

df = pd.concat([stats, hists], sort=False)

if df.empty:
    raise chart.ChartScriptError("The result filter returned no data.")

print(df['min']) # This is the only change
utils.plot_boxwhiskers(df, props)

utils.postconfigure_plot(props)

utils.export_image_if_needed(props)
utils.export_data_if_needed(df, props)

Output:

0    0.004115
1    0.003580
2    0.017635
3    0.005675
4    0.018260
Name: min, dtype: float64

@marsluca marsluca added the new New issue that has not been yet acknowledged label Sep 1, 2024
@torokati44
Copy link
Member

The minimum value is correctly shown by the bottom whisker "protruding into the box", up from the bottom of it to the level 0 - the horizontal minimum indicator just happens to blend into the box, as it's the same color.

What's not correct is the box itself. Since this plot only works from statistics (and histograms), the exact distribution of the collected values is not stored: it's assumed to be a normal one, with the measured mean and standard deviation. This is why the (estimated) IQR can be outside of the (real) min/max range.

Yes, this is an approximation, and can produce artifacts like the above case. The alternative would be to compute the distribution in place, from all values recorded into a vector, as mentioned in #1200.

@marsluca
Copy link
Author
marsluca commented Sep 3, 2024

@torokati44, thanks a lot for your reply.

Yes, this is an approximation, and can produce artifacts like the above case. The alternative would be to compute the distribution in place, from all values recorded into a vector, as mentioned in #1200.

I tried using the code mentioned in #1200, but I still have this issue. What do you mean by "compute the distribution in place"?

This is the obtained graph:
Elephant Flow Completion Time (s) - Box Plot

@torokati44
Copy link
Member
torokati44 commented Sep 3, 2024

What do you mean by "compute the distribution in place"?

Sorry, to be more precise: I meant computing the 25th and 75th percentiles accurately, using the actual set of data points (in a vector); instead of estimating them from the mean and standard deviation, assuming the nature of the distribution to be normal.
Unfortunately, utils.plot_boxwhiskers is currently hard-coded to do the latter...
EDIT: You could, however, take a look inside of it, and call utils.customized_box_plot directly, with the input values set up as needed.

@torokati44 torokati44 added in IDE / result analysis and removed new New issue that has not been yet acknowledged labels Sep 4, 2024
@rhornig rhornig added this to the under review milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0