- Plotly - Discussion
- Plotly - Useful Resources
- Plotly - Quick Guide
- Plotly with Matplotlib and Chart Studio
- Plotly with Pandas and Cufflinks
- Plotly - FigureWidget Class
- Plotly - Slider Control
- Plotly - Adding Buttons/Dropdown
- Plotly - 3D Scatter & Surface Plot
- Plotly - OHLC Chart Waterfall Chart & Funnel Chart
- Plotly - Polar Chart & Radar Chart
- Plotly - Heatmap
- Plotly - Distplots, Density Plot & Error Bar Plot
- Plotly - Box Plot Violin Plot & Contour Plot
- Plotly - Histogram
- Plotly - Dot Plots & Table
- Plotly - Scatter Plot, Scattergl Plot & Bubble Charts
- Plotly - Bar Chart & Pie Chart
- Plotly - Subplots & Inset Plots
- Plotly - Format Axis & Ticks
- Plotly - Legends
- Plotly - Exporting to Static Images
- Plotly - Package Structure
- Plotting Inline with Jupyter Notebook
- Plotly - Online & Offline Plotting
- Plotly - Environment Setup
- Plotly - Introduction
- Plotly - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Plotly - Exporting to Static Images
Outputs of offpne graphs can be exported to various raster and vector image formats. For that purpose, we need to install two dependencies – orca and psutil.
Orca
Orca stands for Open-source Report Creator App. It is an Electron app that generates images and reports of plotly graphs, dash apps, dashboards from the command pne. Orca is the backbone of Plotly s Image Server.
psutil
psutil (python system and process utipties) is a cross-platform pbrary for retrieving information on running processes and system utipzation in Python. It implements many functionapties offered by UNIX command pne tools such as: ps, top, netstat, ifconfig, who, etc. psutil supports all major operating systems such as Linux, Windows and MacOs
Installation of Orca and psutil
If you are using Anaconda distribution of Python, installation of orca and psutil is very easily done by conda package manager as follows −
conda install -c plotly plotly-orca psutil
Since, orca is not available in PyPi repository. You can instead use npm utipty to install it.
npm install -g electron@1.8.4 orca
Use pip to install psutil
pip install psutil
If you are not able to use npm or conda, prebuilt binaries of orca can also be downloaded from the following website which is available at
To export Figure object to png, jpg or WebP format, first, import plotly.io module
import plotly.io as pio
Now, we can call write_image() function as follows −
pio.write_image(fig, ‘sinewave.png’) pio.write_image(fig, ‘sinewave.jpeg’) pio.write_image(fig,’sinewave.webp)
The orca tool also supports exporting plotly to svg, pdf and eps formats.
Pio.write_image(fig, ‘sinewave.svg’) pio.write_image(fig, ‘sinewave.pdf’)
In Jupyter notebook, the image object obtained by pio.to_image() function can be displayed inpne as follows −
Advertisements