import plotly.plotly as py
from plotly.offline import download_plotlyjs, init_notebook_mode, plot,iplot
import plotly.graph_objs as go
init_notebook_mode(connected=True)
data = dict(type = 'choropleth',
locations = ['AZ','CA','NY'],
locationmode = 'USA-states',
colorscale= 'Portland',
text= ['text1','text2','text3'],
z=[1.0,2.0,3.0],
colorbar = {'title':'Colorbar Title'})
layout = dict(geo = {'scope':'usa'})
choromap = go.Figure(data = [data],layout = layout)
py.iplot(choromap)
I've been trying to figure out a way to use plotly on pycharm. When I use the code above, it gives me this error.
plotly.exceptions.PlotlyError: Because you didn't supply a 'file_id' in the call, we're assuming you're trying to snag a figure from a url. You supplied the url, '', we expected it to start with 'https://plot.ly'.
Hi this is my first question on stackoverflow, apologies if my question isn't structured well. Any advice over asking it properly , is greatly appreciated.
The best way to create and view Plotly Figures in PyCharm is using Jupyter Notebooks instead of regular Python Files. To create a Jupyter Notebook in Pycharm, Select File -> New and Select New File. Add the filename ending with .
If you are encountering problems using plotly with Dash please first ensure that you have upgraded dash to the latest version, which will automatically upgrade dash-core-components to the latest version, ensuring that Dash is using an up-to-date version of the Plotly. js rendering engine for plotly .
In Pycharm you have to download it. Go to File --> Settings -->Project --> Project Interpreter --> on the plus right site--> search for your module and download it! Thats it!!
Setting for Offline Plotting Plotly allows you to generate graphs offline and save them in local machine. The plotly. offline. plot() function creates a standalone HTML that is saved locally and opened inside your web browser.
import plotly
from plotly.offline import init_notebook_mode
import plotly.graph_objs as go
plotly.offline.init_notebook_mode(connected=True)
data = dict(type = 'choropleth',
locations = ['AZ','CA','NY'],
locationmode = 'USA-states',
colorscale= 'Portland',
text= ['text1','text2','text3'],
z=[1.0,2.0,3.0],
colorbar = {'title':'Colorbar Title'})
layout = dict(geo = {'scope':'usa'})
choromap = go.Figure(data = [data],layout = layout)
plotly.offline.plot(choromap)
This will definitely work for sure for offline plotting .
You need to authenticate yourself in plotly.
There is a description in the link from point 2 on how to set up your credentials:
import plotly
plotly.tools.set_credentials_file(username='DemoAccount', api_key='lr1c37zw81')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With