I'd like to put in an axspan similar to the following provided in matplotlib so that I have a vertical line in my graph to point out a location. This is for a line chart using pygal
plt.axvspan(fin_loc, fin_loc+1, color='red', alpha=0.5)
It seems that pygal
doesn't support custom additional drawings on its charts.
However vertical lines can be drawn with XY type charts. For example:
chart = pygal.XY()
chart.add('Here is axvspan', [(1, -5), (1, 5)])
But pygal
also doesn't support multiple chart types on one drawing.
So you can draw vertical lines AND line chart with workaround: replace your line chart with XY chart type, draw your vertical line, and then draw your line chart. As XY chart needs two values for each point, you feed it with dummy sequential X values. For example, instead of:
chart = pygal.Line()
chart.add('Chart1', [16, 25, 31])
you write:
chart = pygal.XY()
chart.add('Here is axvspan', [(1, -5), (1, 5)])
chart.add('Chart1', [(1, 16), (2, 25), (3, 31)])
And that's it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With