Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- ax = plt.gca()
- # d is a dictionary from which dataframe is constructed
- df = pd.DataFrame(data=d)
- # to_plot (a function argument) is a dictionary of boolean values to decide what to plot, e.g.
- to_plot = {'A':True,
- 'B':True,
- 'C':False,
- 'D':True}
- if to_plot['A']:
- pl = df['A'].plot(kind='bar', xticks=df.index, title=storage, ax=ax, color='deepskyblue', legend=True)
- if to_plot['B']:
- pl = df['B'].plot(drawstyle='steps-post', xticks=df.index, title=storage, color='lightgreen',
- linewidth=3, ax=ax, legend = True)
- if to_plot['C']:
- pl = df['C'].plot(drawstyle='steps-post', xticks=df.index, title=storage, color='green',
- linestyle='--', linewidth=2, ax=ax, legend=True)
- if to_plot['D']:
- pl = df['D'].plot(drawstyle='steps-post', xticks=df.index, title=storage, color='orange',
- linewidth=3, ax=ax, legend=True)
- if to_plot['A'] or to_plot['B'] or to_plot['C'] or to_plot['D'] :
- plt.legend(loc='best')
- pl.set_xlabel("Time")
- pl.set_ylabel("Storage state(in %)")
- plt.show()
- fig = plt.figure()
- ax = fig.add_axes([0.1, 0.1, 1, 1])
- UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.
- MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
- ax=fig.add_axes([0.1,0.1,1,1])
- WARNING:matplotlib.legend:No handles with labels found to put in legend.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement