I have the above plot, which is almost perfect, but I want to get rid of the 2015, and I have to do it with code not paint.
When I try the following code;
plt.xticks(np.arange(12), calendar.month_name[1:13], rotation=20)
My plot gets all messed up;
How can I use plt.xticks without it squishing all my plot data over to the right hand side?
Related
I'm using matplotlib to show a plot with %matplotlib widget in jupyter lab. Almost every time I show the plot, next thing I have to do is zoom in and examine one of the sections of the plot. I would like to be able to show the plot zoomed into that section, and if I want to examine the rest of the plot, as I sometimes do, I would press back button and see all of it.
This is similar to showing subplot with relevant data or using plt.xlim, except I would like to do it in a single plot so the data I'm looking at can occupy more screen space, and plt.xlim just shows relevant stretch of data without possibility to zoom out again.
How do I do this is jupyter lab?
**Note: My code is at the end of the question.
I want to recreate this chart in matplotlib:
I have come a long way of making something similar but I am stuck in the last part, which is to zoom in the plot to remove all the white space. So basically, I want to zoom in to the red box:
Note that the grid will be removed on the actual chart. Displaying it now to explain what I would like done.
Is that possible? My code is here:
https://github.com/Curbal-Data-Labs/Matplotlib-Labs/blob/master/Polar%20charts/Polar%20bar%20chart.ipynb
EDIT - I was being stupid, and trying to plot strings. I converted to int and plotted again fine. Thanks to ImportanceOfBeingErnest for the hint.
I have data from 3 sensors which I want to plot, using matplotlib
Each array is of different length, and I plot them using the following line of code
plt.plot(s_1,'r',s_3,'b',s_4,'g')
plt.show()
This produces the following graph
As you can see, the green trace is not correct, and the y-axis scale is off (these is a 6 after the 21).
I'm really not sure what the problem is here.
When I plot the data individually, they are fine:
It is the last one in this series that is plotted strangely in the graph with all three at once.
To be clear, I don't understand why separately the graphs plot fine, but when the three are printed in one plot the y-axis gets messed up.
Any advice around what the issue with the three-in-one plot is would be great.
I have a time-series plot of data in which I want to examine a section in more detail. Kind of like this, but with the second plot being below the first, and instead of the box bounding the section of data, bounding the x-axis labels instead.
Is there a simple way to go about this or am I going to have to write this from scratch?
EDIT: This past question seems to be after the same thing, but was never solved.
I am plotting some scalar data as a contour plot with matplotlib.contourf. On top of it, I am plotting some vector data with matplotlib.arrow. The basic plot has come along OK, but now I need to put a box on the plot with a default-size arrow plus the data value to which it corresponds, so the viewer will know what kind of scale he is looking at. For instance, I need a box with a horizontal arrow of some length and, below that, some text like "10 cm/sec".
First, if anyone can give me a simple approach to this, I would be grateful.
Second, the approach I have tried is to do the contour plot, then plot the arrows, then add a rectangle to the plot like so:
rect=pl.Rectangle((300,70),15,15,fc='white')
pl.gca().add_patch(rect)
and then, finally, put my scale arrow and text on top of this rectangle.
This isn't working because the rectangle patch covers up the contour, but it doesn't cover up the arrows in the plot. Is there a way to move the patch completely "to the front" of everything else?
Got it. Using pylab.quiver and pylab.quiverkey functions. quiver produces a nice vector field with just a few lines of code, and quiverkey makes it easy to produce a scaling vector with text. And, for some reason, the arrows plotted with quiver are indeed covered by my rectangle, so it is easy to make the scaling arrow very visible. There are still some mysteries in all of this for me. If anyone wants to try to clear them up, would be much obliged. But I have a way now to do what I need in this instance.