1
在具有颜色编码点此纬度/经度散点图:Matplotlib pyplot 2D散射没有轴,添加共享轴标签
我想有没有轴但具有用于x轴的共用标签和y轴。所有我尝试使用轴标签都会失败,因为标签在没有可见轴的情况下不显示。
下面列出了没有这些错误的工作代码。
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("_test.csv")
power = df['n']
lat = df['latitude']
lon = df['longitude']
df = pd.read_csv("shifted3.csv")
power = df['n']
lat = df['latitude']
lon = df['longitude']
plt.subplot(121)
plt.scatter(lon, lat, c=power,s=65, vmin=0, vmax=3700)
# c= sets how the points are coloured, s= point size, vmin/max colour lims
plt.title('a) AGW')
plt.ylim(ymin=51.44,ymax=51.73)
plt.xlim(xmin=1.42, xmax=1.63)
plt.axis('off')
cbar = plt.colorbar()
cbar.ax.set_yticklabels(['0','','','','','','','','','3600'])
plt.subplot(122)
#plt.figure(figsize=(5,10))
plt.scatter(lon, lat, c=power,s=65, vmin=0, vmax=3700)
# c= sets how the points are coloured, s= point size, vmin/max colour lims
plt.title('b) no event')
plt.xlim(xmin=2.23, xmax=2.45)
plt.ylim(ymax=52.09)
plt.axis('off')
# #
cbar = plt.colorbar()
cbar.ax.set_yticklabels(['0','','800','','1600','','2400','','','3600'])
cbar.set_label('Power (kW)', rotation=270, labelpad=+12)
#labelpad + moves legend to right, - to left
plt.show()
这并回答你的问题? http://stackoverflow.com/questions/29041326/3d-plot-with-matplotlib-hide-axes-but-keep-axis-labels – periphreal
很难理解你真正想达到的目标。 “我想要没有坐标轴” - 您显示的坐标图没有任何坐标轴。 “...但为x轴和y轴共享标签”x和y如何共享标签?该标签在哪里? – ImportanceOfBeingErnest
道歉@ImportanceOfBeingErnest,我的意思是在两个情节的左边的subplots和一个单一的y轴共享x标签。 –