English 中文(简体)
Plotly with Matplotlib and Chart Studio
  • 时间:2024-12-22

Plotly with Matplotpb and Chart Studio


Previous Page Next Page  

This chapter deals with data visuapzation pbrary titled Matplotpb and onpne plot maker named Chart Studio.

Matplotpb

Matplotpb is a popular Python data visuapzation pbrary capable of producing production-ready but static plots. you can convert your static matplotpb figures into interactive plots with the help of mpl_to_plotly() function in plotly.tools module.

Following script produces a Sine wave Line plot using Matplotpb’s PyPlot API.


from matplotpb import pyplot as plt
import numpy as np
import math 
#needed for definition of pi
x = np.arange(0, math.pi*2, 0.05)
y = np.sin(x)
plt.plot(x,y)
plt.xlabel("angle")
plt.ylabel("sine")
plt.title( sine wave )
plt.show()

Now we shall convert it into a plotly figure as follows −


fig = plt.gcf()
plotly_fig = tls.mpl_to_plotly(fig)
py.iplot(plotly_fig)

The output of the code is as given below −

Matplotpb

Chart Studio

Chart Studio is an onpne plot maker tool made available by Plotly. It provides a graphical user interface for importing and analyzing data into a grid and using stats tools. Graphs can be embedded or downloaded. It is mainly used to enable creating graphs faster and more efficiently.

After logging in to plotly’s account, start the chart studio app by visiting the pnk https://plot.ly/create. The web page offers a blank work sheet below the plot area. Chart Studio lets you to add plot traces by pushing + trace button.

Chart Studio

Various plot structure elements such as annotations, style etc. as well as facipty to save, export and share the plots is available in the menu.

Let us add data in the worksheet and add choose bar plot trace from the trace types.

Choose Bar

Cpck in the type text box and select bar plot.

Select Bar

Then, provide data columns for x and y axes and enter plot title.

Data Columns Advertisements