I am new to matplotlib and I am trying to figure out if I can repeat the y axis scale values along the grid lines of the line graph.
The graph has 2 axis, x-axis has hourly values and y-axis has temperature values.
I need to show the graph for 48 hours, so it results in a long horizontal graph. when user scrolls through the graph horizontally he has x-axis scale available for reference but y axis scale is way towards left and is not visible.
I need a way to repeat the y-axis scale(temperature values) along all the graph. Is there any way to achieve this?
Is there any better solution to this problem, apart from repeating the values?
You might take a look at the colorbar from this example :
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.collections import EllipseCollection
x = np.arange(10)
y = np.arange(15)
X, Y = np.meshgrid(x, y)
XY = np.hstack((X.ravel()[:,np.newaxis], Y.ravel()[:,np.newaxis]))
ww = X/10.0
hh = Y/15.0
aa = X*9
ax = plt.subplot(1,1,1)
ec = EllipseCollection(
ww,
hh,
aa,
units='x',
offsets=XY,
transOffset=ax.transData)
ec.set_array((X+Y).ravel())
ax.add_collection(ec)
ax.autoscale_view()
ax.set_xlabel('X')
ax.set_ylabel('y')
cbar = plt.colorbar(ec)
cbar.set_label('X+Y')
plt.show()
A quick experiment shows me that you can pan/zoom the main window and the colorbar will stay constant.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.