Adjust axes with matplotlib

I thought I'd explain it myself, but since ʻaxis` is too convenient to say, I'll post a Japanese translation of the manual. Please see nbviewer for a display example.

matplotlib.pyplot.axis(*v, **kwargs)

Convenience method to get or set axis properties. This is a convenient way to set and get the axes.

Calling with no arguments: When called with no arguments:

axis()

returns the current axes limits [xmin, xmax, ymin, ymax].: Returns the maximum / minimum of the currently displayed coordinates in the format [xmin, xmax, ymin, ymax].

axis(v)

sets the min and max of the x and y axes, with v = [xmin, xmax, ymin, ymax].: Calling with v = [xmin, xmax, ymin, ymax] as an argument sets the maximum and minimum of x and y, respectively.

axis('off')

turns off the axis lines and labels.: Hide the axes.

axis('equal')

changes limits of x or y axis so that equal increments of x and y have the same length; a circle is circular.: Adjust the upper and lower limits of x or y so that the increments of the same coordinate value have the same length. The circle is displayed properly in a circle.

axis('scaled')

achieves the same result by changing the dimensions of the plot box instead of the axis data limits.: You can get the same effect (as in the case of'equal') by adjusting the displayed area (with the upper and lower limits unchanged).

axis('tight')

changes x and y axis limits such that all data is shown. If all data is already shown, it will move it to the center of the figure without modifying (xmax - xmin) or (ymax - ymin). Note this is slightly different than in MATLAB.: Change the maximum / minimum so that all data can be seen. If you can already see it, move the display area to the center without changing (xmax --xmin) or (ymax --ymin). Please note that it is slightly different from the case of MATLAB.

axis('image')

is ‘scaled’ with the axis limits equal to the data limits.: After using the maximum and minimum of the data, the effect of'scaled'is further obtained.

axis('auto')

and: When

axis('normal')

are deprecated. They restore default behavior; axis limits are automatically scaled to make the data fit comfortably within the plot box. Will be abolished. These restore the default settings. Make sure the data fits nicely into the plot area.

if len(*v)==0, you can pass in xmin, xmax, ymin, ymax as kwargs selectively to alter just those limits without changing the others. When len (* v) == 0, xmin, xmax, ymin, ymax can be selectively given as keyword arguments. The settings that were not given at this time will be reflected as they are.

The xmin, xmax, ymin, ymax tuple is returned

See also

xlim(),ylim() For setting the x- and y-limits individually.

Recommended Posts

Adjust axes with matplotlib
Animation with matplotlib
Japanese with matplotlib
Animation with matplotlib
Histogram with matplotlib
Animate with matplotlib
Adjust the spacing between figures with Matplotlib
2-axis plot with Matplotlib
Heatmap with Python + matplotlib
Learn with Cheminformatics Matplotlib
Various colorbars with Matplotlib
Adjust the ratio of multiple figures with the matplotlib gridspec
Graph Excel data with matplotlib (1)
Try using matplotlib with PyCharm
Graph drawing method with matplotlib
Graph Excel data with matplotlib (2)
Stackable bar plot with matplotlib
Gradient color selection with matplotlib
Animate multiple graphs with matplotlib
Adjust hyperparameters with Bayesian optimization
Create plot animation with Python + Matplotlib
A python graphing manual with Matplotlib.
Japaneseize Matplotlib with Alpine using Docker
[Python] font family and font with matplotlib
Show axes as percentages in Matplotlib
Draw a loose graph with matplotlib
Versatile data plotting with pandas + matplotlib
[Introduction to Matplotlib] Axes 3D animation: I played with 3D Lissajous figures ♬
Heatmap with Dendrogram in Python + matplotlib
Easy Japanese font setting with matplotlib
Easy to draw graphs with matplotlib
Continuously color with matplotlib scatter plot
Draw Lyapunov Fractal with Python, matplotlib
When matplotlib doesn't work with python2.7
Easy animation with matplotlib (mp4, gif)
Write a stacked histogram with matplotlib
Adjust the bin width crisply and neatly with the histogram of matplotlib and seaborn
How to title multiple figures with matplotlib
Adjust widget styles and layouts with ipywidgets
Align the size of the colorbar with matplotlib
Try drawing a normal distribution with matplotlib
Make a partially zoomed figure with matplotlib
Write SVG graphs with matplotlib on heroku
Heat Map for Grid Search with Matplotlib
Set the xticklabels color individually with matplotlib
Draw hierarchical axis labels with matplotlib + pandas
[Python] Let's make matplotlib compatible with Japanese
Graph trigonometric functions with numpy and matplotlib
Display markers above the border with matplotlib
Matplotlib Basics / Differences between fig and axes
Match the colorbar to the figure with matplotlib
Use Axes objects created individually with seaborn
[Jupyter Notebook memo] Display kanji with matplotlib
Write a nice pie chart with matplotlib
Make common settings with subplot of matplotlib
Create a graph with borders removed with matplotlib