[ZEPPELIN-502] Improve python.md

This commit is contained in:
Hervé RIVIERE 2016-05-19 23:43:49 +02:00
parent 50081253e5
commit c62ac98387

View file

@ -42,7 +42,7 @@ The interpreter can use all modules already installed (with pip, easy_install...
## Apply Zeppelin Dynamic Forms
You can leverage [Zeppelin Dynamic Form]({{BASE_PATH}}/manual/dynamicform.html) inside your Python code.
Example :
```bash
```python
%python
# Input fom
print (z.input("f1","defaultValue"))
@ -63,8 +63,8 @@ print("".join(z.checkbox("f3", [("o1","1"), ("o2","2")],["1"])))
## Matplotlib integration
The python interpreter can display matplotlib graph with the function **_zeppelin_show()_**
You need to already have matplotlib module installed to use this functionality !
```bash
You need to already have matplotlib module installed and a running XServer to use this functionality !
```python
%python
import matplotlib.pyplot as plt
plt.figure()
@ -73,7 +73,7 @@ zeppelin_show(plt)
plt.close()
```
zeppelin_show function can take optional parameters to adapt graph width and height
```bash
```python
%python
zeppelin_show(plt,width='50px')
zeppelin_show(plt,height='150px')
@ -81,14 +81,6 @@ zeppelin_show(plt,height='150px')
[![pythonmatplotlib](/docs/interpreter/screenshots/pythonMatplotlib.png)](/docs/interpreter/screenshots/pythonMatplotlib.png)
### Use matplotlib without XServer
Matplotlib needs a X server to plot graph.
If you don't have any XServer and you don't want to install one (typically, a server environment) , you can use [Xvfb](http://www.x.org/archive/X11R7.6/doc/man/man1/Xvfb.1.xhtml) to simulate it.
Althought Xvfb doesn't display anything, you will have any issue to use the python interpreter, matplotlib and Xvfb. The interpreter plot the graph on X and then extracts svg path (in strings) to send it to the zeppelin webapp.
## Technical description - Interpreter architecture