Created
August 4, 2020 22:16
-
-
Save sabopy/15244ff667a39a77642abc2e46217355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
x,y = np.meshgrid(np.linspace(0.1,0.9,9),np.linspace(0.1,0.9,9)) | |
#xlabel position | |
fig,ax = plt.subplots(1,3,figsize=(8,3)) | |
ax = ax.ravel() | |
fig.patch.set_facecolor('white') | |
loc=['left','center','right'] | |
for a,i in zip(ax,range(3)): | |
a.patch.set_facecolor('k') | |
a.grid(color='gray', linestyle='-', linewidth=4) | |
a.tick_params(labelbottom=False, labelleft=False) | |
a.tick_params(color='white') | |
a.plot(x,y,'o',c='white', ms=3) | |
a.set_xlabel('xlabel loc='+str(loc[i])+'', loc=loc[i]) | |
a.xaxis.set_major_locator(plt.MaxNLocator(10)) | |
a.yaxis.set_major_locator(plt.MaxNLocator(10)) | |
a.set_box_aspect(1) | |
plt.tight_layout() | |
plt.savefig("kirameki_xlabel.png",dpi=100, pad_inches = 'tight') | |
plt.show() | |
#ylabel position | |
fig,ax = plt.subplots(1,3,figsize=(8,3)) | |
ax = ax.ravel() | |
fig.patch.set_facecolor('white') | |
loc=['bottom', 'center', 'top'] | |
for a,i in zip(ax,range(3)): | |
a.patch.set_facecolor('k') | |
a.grid(color='gray', linestyle='-', linewidth=4) | |
a.tick_params(labelbottom=False, labelleft=False) | |
a.tick_params(color='white') | |
a.plot(x,y,'o',c='white', ms=3) | |
a.set_ylabel('xlabel loc='+str(loc[i])+'', loc=loc[i]) | |
a.xaxis.set_major_locator(plt.MaxNLocator(10)) | |
a.yaxis.set_major_locator(plt.MaxNLocator(10)) | |
a.set_box_aspect(1) | |
plt.tight_layout() | |
plt.savefig("kirameki_ylabel.png",dpi=100, pad_inches = 'tight') | |
plt.show() | |
x,y = np.meshgrid(np.linspace(0.1,0.9,9),np.linspace(0.1,0.9,9)) | |
#xlabel position | |
fig,ax = plt.subplots(1,3,figsize=(8,3)) | |
ax = ax.ravel() | |
fig.patch.set_facecolor('white') | |
pad=[10,20,30] | |
for a,i in zip(ax,range(3)): | |
a.patch.set_facecolor('k') | |
a.grid(color='gray', linestyle='-', linewidth=4) | |
a.tick_params(labelbottom=False, labelleft=False) | |
a.tick_params(color='white') | |
a.plot(x,y,'o',c='white', ms=3) | |
a.set_xlabel('labelpad='+str(pad[i])+'',labelpad=pad[i]) | |
a.xaxis.set_major_locator(plt.MaxNLocator(10)) | |
a.yaxis.set_major_locator(plt.MaxNLocator(10)) | |
a.set_box_aspect(1) | |
plt.tight_layout() | |
plt.savefig("kirameki_xlabelpad.png",dpi=100, pad_inches = 'tight') | |
plt.show() | |
#version | |
import matplotlib | |
print(matplotlib.__version__) | |
3.3.0 | |
print(np.__version__) | |
1.19.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment