0

I'm looking for some advice about how to achieve the wanted result.

Basically I have columns in my df that are measures of the same variable for different categories, like this:

 TIME | var_X_group_A | var_X_group_B | var_Y_group_A | var_Y_group_B
18:00 |           120 |           330 |            11 |            12
19:00 |           110 |           230 |             8 |            18
20:00 |           ... |           ... |           ... |           ...

I'm plotting them with matplotlib using the following code:

df.plot(x = "TIME", y=["var_X_group_A", "var_X_group_B"], figsize=(15, 5), title = "var X")
ax = plt.axes()  
ax.yaxis.set_label_text('var X')
ax.yaxis.grid(True)

df.plot(x = "TIME", y=["var_Y_group_A", "var_Y_group_B"], figsize=(15, 5), title = "var Y")
ax = plt.axes()  
ax.yaxis.set_label_text('var Y')
ax.yaxis.grid(True)

I'm having some hard times structuring these two plots in a single figure with subplot and save such figure as .pdf

Moreover I would also like to add a 'trend line' at the average value, with a little label displaying the average value.

Thank you for all the support

carloab
  • 37
  • 6
  • I'm looking at the answers in the similar thread linked in the duplicae warning. Actually I've seen many example like those made there but they all use a different syntax and I can't get the arguments working with my objects. The code I'm using for each single plot is working fine, can't I put them together keeping this syntax? Thank you! – carloab Jul 24 '18 at 17:18
  • Have you tried to adapt the subplot examples displayed in the [matplotlib sample gallery?](https://matplotlib.org/examples/pylab_examples/subplots_demo.html) Your question is not well-suited for SO, as it contains three different problems but no [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Mr. T Jul 24 '18 at 17:51

0 Answers0