Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the axis limit in a matplotlib plt.polar plot

Say I have the following polar plot:

a=-0.49+1j*1.14
plt.polar([0,angle(x)],[0,abs(x)],linewidth=5)

matplotlib polar plot

And I'd like to adjust the radial limits to 0 to 2.

What is the best way to do this?

Note that I am asking specifically about the plt.polar() method (as opposed to using polar=True parameter in a normal plot common in similar questions).

This seems to work, unless I'm plotting from the console (Spyder, Win7):

>>> ax=plt.gca()
>>> ax.set_rlim(0,2)
like image 450
atomh33ls Avatar asked May 19 '15 15:05

atomh33ls


People also ask

What are the two ways to adjust axis limits of the plot using Matplotlib?

To plot the graph, use the plot() function. To set the limit of the x-axis, use the xlim() function. To set the limit of the y-axis, use the ylim() function.

How do I limit in Matplotlib?

Matplotlib automatically arrives at the minimum and maximum values of variables to be displayed along x, y (and z axis in case of 3D plot) axes of a plot. However, it is possible to set the limits explicitly by using set_xlim() and set_ylim() functions.

What does PLT axis off do?

To hide the axes, use plt.axis('off') To activate the labels' legend, use the legend() method. To display the figure, use the show() method.


1 Answers

An easier approach to solve the OP may be:

ax.set_ylim([0,2])
like image 88
Lost_New_User Avatar answered Nov 01 '22 15:11

Lost_New_User