Python Forum

Full Version: Where's the endless loop?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(Oct-04-2021, 04:37 PM)deanhystad Wrote: [ -> ]Your code was taking a long time when you added bars to the chart one at a time. Now you plot all the bars at once, just like I am doing. Looping to group the data will be slower than using the dataset functions, but the difference is so minor when compared to drawing a plot that it is lost in the noise.

Ohhhh okay... I misunderstood the source of the delay.

In my initial attempt, I did not realize I was adding bars one at a time. In the end, why was the output four blank subplots rather than four subplots with a single bar?

Mark
You were plotting a bar at a time. That does not mean there is only one bar. You can add data points to an existing plot.

I don't know which version you refer to. I thought you were getting one plot with bars and three blank plots. I don't remember you mentioning a time when there was no plot at all.
(Oct-04-2021, 04:51 PM)deanhystad Wrote: [ -> ]You were plotting a bar at a time. That does not mean there is only one bar. You can add data points to an existing plot.

I don't know which version you refer to. I thought you were getting one plot with bars and three blank plots. I don't remember you mentioning a time when there was no plot at all.

Please see response #7 in this thread.

Mark
The plots were blank because you called .plot instead of .bar. .plot draws a line graph. Normally lines are drawn between points, but since you plotted one point at a time there were no lines. Your plots actually contained points, but since you didn't specify a marker the points were invisible.

If you want to see what the plots look like with visible markers, change you plot command to this:
ax[0,0].plot(key,my_dict[key], marker='o')
You should really put aside some time to read the pyplot documentation.
(Oct-04-2021, 06:25 PM)deanhystad Wrote: [ -> ]The plots were blank because you called .plot instead of .bar. .plot draws a line graph. Normally lines are drawn between points, but since you plotted one point at a time there were no lines. Your plots actually contained points, but since you didn't specify a marker the points were invisible.

If you want to see what the plots look like with visible markers, change you plot command to this:
ax[0,0].plot(key,my_dict[key], marker='o')
You should really put aside some time to read the pyplot documentation.

I will. Thank you!
Pages: 1 2