【发布时间】:2019-04-25 17:46:41
【问题描述】:
我有一张英国地图和 121 个地点,每个地点都有 3 个值。我想在 121 个位置中的每一个位置绘制三个值的小条形图。
目前,这些值被绘制为markersize 属性,如下所示:
Trypophobic_Plot
使用以下代码制作:(大量简化)
fig, ax = plt.subplots()
ax = Basemap(llcrnrlat= 46.351611,
llcrnrlon= -11.543011,
urcrnrlat= 60.417133,
urcrnrlon= 6.2743413,
resolution='i', projection='tmerc', lon_0=-2, lat_0=49)
#Draw Coastlines, colours etc.
(removed because not important to this example)
################################################
# Plot Network edge map
(not important to this example)
################################################
# Plot SYNOP Station Points
lats = [59.5329945921, 58.9499976059, 57.3669959942...]
lons = [-1.63299557989, -2.90000295719, -7.40000487601...]
for method in range (0,3):
for i in range(0, len(lons)):
x,y = ax(lons[i], lats[i])
ax.plot(x, y, 'o', color=(1,1,1,0), \
markersize= ..., \
markeredgecolor=..., \
markeredgewidth=7)
################################################
# Other plot features
plt.text(10000, 10000,'Max: = ' ... + \
'\nMin: = ' ..., \
fontsize=32, zorder=75.)
plt.title('site_scores' , fontsize=30)
plt.show()
但是,我想要一个条形图。我解决这个问题的方法是为 121 个位置中的每一个创建一个子图。这可能效率低下,因此如果您认为有更好的方法,请提出另一种方法。
我尝试过的事情:
我开始研究在纬度/经度和图表的实轴之间进行转换,这有点令人困惑。有display、axes、data 和Figure。我无法在这里应用变换操作数:https://matplotlib.org/users/transforms_tutorial.html 到 ax 坐标上。您可以在上面的代码中看到我是如何制作圆圈的,但我不知道将它们切换到什么坐标系。
然后我想我会尝试添加一个我通常做的轴操作系统,然后看看它出现在哪里。像这样:
ax3 = fig.add_axes([0.5,0.5, 0.2, 0.2])
但这会导致绘图大小出现错误:
ValueError: Image size of 5690009x6001228 pixels is too large. It must be less than 2^16 in each direction.
这就是我目前的目标。我想要一个小条形图来显示这些圆圈的大小。
【问题讨论】: