In a discrete time-series graph, I have tried replacing ax.plot(x,y)
by ax.vlines(x,y)
:
- I get the error:
vlines() missing 1 required positional argument: 'ymax'
However, I cannot know the ymax
value beforehand.
How can I avoid this error ?
Should I compute this value by parsing all the data to display ? Is there a way to tell matplotlib to automatically adapt to the data ?
Some more details about the graph:
The graph is not accurate, due to the drawing of a continuous curve, whereas my data is instead a distribution of discrete values over time. This is why I want to use vlines
.
This is the code I create the graph with:
(The exception_time_series object is an object that counts the number of a given exception type at a given time in a program).
fig = figure(1)
for exception_time_series in exceptions_time_series.list_exception_time_series:
time_values, series_values = exception_time_series.time_values, exception_time_series.series_values
ax = fig.add_subplot(111, autoscale_on=True )
dates = np.array(time_values)
x = dates
y = np.array(series_values)
ax.plot(x, y, label=exception_time_series.exception) # <=== using plot
ax.legend()
show()
And that's the graph I'm getting right now:
But I would like to get something of that kind, (that would reflect that it is a irregular distribution over time):