:PROPERTIES: :header-args:python: :session figs :header-args: :results output scalar drawer replace :END: #+TITLE: plotting in python with plotly example #+begin_src python :results none import pandas as pd import plotly.express as px #+end_src #+begin_src python data = dict(x=[1,2,3,4,5,6],y=[9,8,7,6,5,4]) df = pd.DataFrame(data) df #+end_src #+begin_src python :results file link :file fig.svg :post wrap(*this*, w="500pt") p = px.scatter( df, x='x', y='y', ) p.write_image("fig.svg") #+end_src #+RESULTS: : #+attr_latex: :width 500pt : [[file:fig.svg]] # the post-processed results are quoted verbatim. # a drawer is preferred to facilitate viewing the figure. #+NAME: wrap #+begin_src sh :var p="" :var w="300pt" echo -ne "#+attr_latex: :width $w\n$p" #+end_src