Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib set shared axis

Tags:

Using matplotlib, it seems the only time to set the sharex or sharey axis parameters are during sub_plot creation (add_subplot(), subplot(), subplots()). For an axes class there are methods for getting axis sharing (get_shared_x_axes(), get_shared_y_axes()), but no corresponding methods for setting sharing. Maybe this is an API oversight, or perhaps it did not fit architecturally.

Is there a way to change the shared axis parameter?

For those that ask why: I'm using a matrix of plots dynamically, and can control this using view limits, but it just seems like there could be an easier way, and turning sharing on/off and using autoscale would be it.

Thanks.

like image 728
CNK Avatar asked Jun 26 '13 19:06

CNK


People also ask

What is sharey true?

Controls sharing of properties among x ( sharex ) or y ( sharey ) axes: True or 'all': x- or y-axis will be shared among all subplots. False or 'none': each subplot x- or y-axis will be independent.

How do you plot on the same graph in Python?

Call matplotlib. pyplot. plot(x, y) with x and y set to arrays of data points to construct a plot. Calling this function multiple times on the same figure creates multiple plots in the same graph.

What is Sharex false?

If sharex is set to False or none , each x-axis of a subplot will be independent. If it is set to row , each subplot row will share an x-axis. If it is set to col , each subplot column will share an x-axis. sharey.


1 Answers

Just to mention that a method for sharing axes after their creation does exist by now. For two axes ax1 and ax2 you can use

ax1.get_shared_x_axes().join(ax1, ax2) 

See How share x axis of two subplots after they are created?.

like image 130
ImportanceOfBeingErnest Avatar answered Sep 17 '22 15:09

ImportanceOfBeingErnest