This is a web-based interface for creating and editing Matplotlib figures for data scientists.
Here I would like to present you with a web-based interface for creating and editing Matplotlib figures. For data and other scientists!
Requirements:
Instructions:
Done. Everything is installed.
cd "/Users/artemn9/m-f/"
In my case the output is:
env FLASK_APP=main:app flask run
* Serving Flask app "main:app"
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
In your browser go to the local address written above: e.g., http://127.0.0.1:5000/
You will see your browser window looking like this:
Click the button on the right “Initialize” so it changes label to “Run everything”.
Done. You are ready to use it.
Put this code:
columns = 'resid1 resid2 resid3 resid4 resid5'.split(' ')
df = pd.DataFrame(np.random.randn(100, 5), columns=columns)
into the “Python Code” editor box:
Click a green button above the Python editor “Run code only”.
Put the following JSON code:
{
'plot.bar': {
'y': ['resid2', 'resid3', 'resid4'],
'color': ['#6abc17','#fad206','#ff4770'],
'alpha': 0.9,
'grid': 0,
'title': ".py str(\'This is my\'+\' Whatever picture\')"
},
'axes': {
'xlim': [20,80],
'xticks': ".py [10*x for x in range(11)]",
'xticklabels': ".py [str(10*x)+\' obs.\' for x in range(11)]",
'xlabel': 'Observation ids',
'ylabel': 'Residual value'
},
'figure': {
}
}
into the “Figure Parameters” editor box:
Click a green button above the figure parameters editor “Create figure only”.
The first branch of the JSON is “plot.bar” in this example. However, you can input any plotting function “x.y or x” which can produce plots out of a DataFrame “df” as “df.x.y(…) or df.x(…)”. The content of the “plot.bar” branch would be “keyword-unpacked” when calling “df.plot.bar(kwgs)”.**
You will see the result:
Note that you could type inline python code within your JSON values by typing “.py “ (with a whitespace) in front of your inline python code. Flask server will pre-process these strings and replace them with the resulting values.
after the figure has been created.
plt.xticks(rotation=35)
Then click the black button “Run everything” on the right. You will see the result:
Now you can either “Save as” the result in the png format, or do anything directly to the “fig” global variable, e.g. dump it in a file to use later by putting the code below in the “Python Code” editor box and clicking the “Run code only” button:
from pickle import dump
with open('/Users/artemn9/Desktop/figure.dump', 'wb') as f:
dump(fig, f)
Best Regards,
Artem Neklyudov