I am setting up some code such that prior to plotting, the user can basically store all the plotting variables that they want to use in a dictionary, and these entries are stored for later use. The keys to the dictionary follow matplotlib.pyplot keyword syntax. An example of this dictionary would be something like this:
plot_info = {'title':'A neato title!',
'x':[1,2,3,4],
'y':[5,6,7,8],
'grid':'on'}
How do I bring this dictionary into a plot command to execute the keys as arguments and the parameters as inputs to those arguments?
Thus far, I have attempted:
import matplotlib.pyplot as plt
plot_info = {'title':'A neato title!',
'x':[1,2,3,4],
'y':[5,6,7,8],
'grid':'on'}
plt.plot(**plot_info)
Expecting this to do the trick. However, upon running the code, the figure pops up, but the figure is empty and everything is blank (runs without error but opens an empty figure).
I expect the output to display a plot whose title, x, and y values correspond to the dictionary values, and whose grid is on. Any idea why this plot would be blank?
For the record, I know that there are workarounds, and that this can be solved another way. However, I am curious as to why this is happening.