0

I am new to plotting in python. I want to make a county choropleth. I'm attempting the code below. I get no errors but I also get no plot. I assumed a separate window would appear with my visual in it. Spyder just ran the code and nothing. I'm new to python so maybe my expectations are wrong. Thanks in advance.

import plotly.figure_factory as ff

fips = ['06021', '06023', '06027',
        '06029', '06033', '06059',
        '06047', '06049', '06051',
        '06055', '06061']
values = range(len(fips))

fig = ff.create_choropleth(fips=fips, values=values)
fig.layout.template = None
fig.show()

When I run this:

import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()

a plot is produced.

Found a solution. The problem is the code below plots the results in a new browser window as a html type thing. I plan on incorporating this output into a Microsoft PowerBI dashboard. Thus, I think I need the output to appear in the Ipython console. I'm using spyder.

fips    values
01234   2348564 
12356   897
10012   984375
fips = y_2017['NewFIPS'].tolist()
values = y_2017['Yr_Neg_Money_Cnty'].tolist()

colorscale=["#f7fbff","#ebf3fb","#deebf7","#d2e3f3","#c6dbef",
            "#b3d2e9","#9ecae1", "#85bcdb","#6baed6",
            "#57a0ce","#4292c6","#3082be","#2171b5",
            "#1361a9","#08519c","#0b4083","#08306b"]

endpts = list(np.linspace(1, 3000000, len(colorscale) - 1))

fig = ff.create_choropleth(fips=fips, values=values, colorscale= colorscale, binning_endpoints=endpts)
py.offline.plot(fig)

fig.show() might be what I'm looking for but still cannot get it to work.

wolf7687
  • 135
  • 8

0 Answers0