I'm sorry it's not a good article, but I wrote it down because I always forget it and have a hard time when I correct the figure before submitting the paper.
fig = plt.figure(figsize=(15,3))
Coordinate specification by relative ratio
ax.annotate('Test', xy=(0, 1.1), xycoords='axes fraction', fontsize=16)
Coordinate specification at data points
ax.annotate('Test', xy=(0, 0.1), xycoords='data', fontsize=16)
Above ax. Somehow
ax = fig.add_subplot(1,1,1)
It is ax. The same notation is used below.
ax.xaxis.set_ticklabels([])
ax.axes.get_xaxis().set_ticks([])
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
ax.xaxis.set_major_formatter(FormatStrFormatter("%.1f"))
ax.yaxis.set_major_formatter(FormatStrFormatter("%1.e"))
plt.gca().invert_xaxis()
plt.tick_params(labelsize=20)
In this case, it is necessary to acquire the data ratio of plot before using it. That is, in the case of 0.7, after ax.plot
ax.set_aspect(0.7/ax.get_data_ratio())
colorbar(bar,shrink=0.3)
cbar=colorbar(bar, orientation='horizontal')
cbar.set_label(‘color label',size=14)
from matplotlib.colors import LogNorm
bar=ax.imshow(stdall,vmin=0.01,vmax=1.0,extent[w[0],w[-1],2250.0,6750.0],\
interpolation='nearest',cmap="hot",norm=LogNorm())
cbar=colorbar(bar, orientation='horizontal',ticks=\
[0.05,0.06,0.07,0.08,0.09,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0])
from mpl_toolkits.axes_grid1 import make_axes_locatable
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(a, cax=cax)
fig.subplots_adjust(bottom=0.2)
plt.savefig("figure1.pdf", bbox_inches="tight", pad_inches=0.0)
Recommended Posts