使用plotly时如何纠正值错误

时间:2018-09-02 11:23:16

标签: python plotly data-science

我的代码

 gun_states=gun['state'].value_counts().head(30)

gun_states.iplot(kind='bar',,xTitle="states",yTitle="Counts",title="Top states with gun violence")

我的输出

  ValueError               Traceback (most recent call last)
  <ipython-input-191-d636769fcf8e> in <module>()
  1 gun_states=gun['state'].value_counts().head(30)
  2 
  ----> 3 gun_states.iplot(kind='bar')

 ~\AnacondaNew\lib\site-packages\cufflinks\plotlytools.py in _iplot(self,kind, data, layout, filename, sharing, title, xTitle, yTitle, zTitle, theme, colors, colorscale, fill, width, dash, mode, interpolation, symbol, size, barmode, sortbars, bargap, bargroupgap, bins, histnorm, histfunc, orientation, boxpoints, annotations, keys, bestfit, bestfit_colors, mean, mean_colors, categories, x, y, z, text, gridcolor, zerolinecolor, margin, labels, values, secondary_y, secondary_y_title, subplots, shape, error_x, error_y, error_type, locations, lon, lat, asFrame, asDates, asFigure, asImage, dimensions, asPlot, asUrl, online, **kwargs)
761 bargap=bargap,bargroupgap=bargroupgap,annotations=annotations,gridcolor=gridcolor,
762 dimensions=dimensions,
--> 763 zerolinecolor   =zerolinecolor,margin=margin,is3d='3d' in kind,**l_kwargs)
764 
765         if not data:

~\AnacondaNew\lib\site-packages\cufflinks\tools.py in getLayout(kind,  theme, title, xTitle, yTitle, zTitle, barmode, bargap, bargroupgap, margin, dimensions, width, height, annotations, is3d, **kwargs)
199 
200         theme_data = getTheme(theme)
--> 201         layout=go.Layout(theme_data['layout'])
202         layout['xaxis1'].update({'title':xTitle})
203         layout['yaxis1'].update({'title':yTitle})

~\AnacondaNew\lib\site-packages\plotly\graph_objs\_layout.py in __init__(self, arg, angularaxis, annotations, autosize, bargap, bargroupgap, barmode, barnorm, boxgap, boxgroupgap, boxmode, calendar, colorway, datarevision, direction, dragmode, font, geo, grid, height, hiddenlabels, hiddenlabelssrc, hidesources, hoverdistance, hoverlabel, hovermode, images, legend, mapbox, margin, orientation, paper_bgcolor, plot_bgcolor, polar, radialaxis, scene, selectdirection, separators, shapes, showlegend, sliders, spikedistance, template, ternary, title, titlefont, updatemenus, violingap, violingroupgap, violinmode, width, xaxis, yaxis, **kwargs)

 ~\AnacondaNew\lib\site-packages\plotly\basedatatypes.py in   __setattr__(self, prop, value)

~\AnacondaNew\lib\site-packages\plotly\basedatatypes.py in __setattr__(self, prop, value)

~\AnacondaNew\lib\site-packages\plotly\graph_objs\_layout.py in legend(self, val)

~\AnacondaNew\lib\site-packages\plotly\basedatatypes.py in __setitem__(self, prop, value)

~\AnacondaNew\lib\site-packages\plotly\basedatatypes.py in __setitem__(self, prop, value)

~\AnacondaNew\lib\site-packages\plotly\basedatatypes.py in _set_compound_prop(self, prop, val)

~\AnacondaNew\lib\site-packages\_plotly_utils\basevalidators.py in validate_coerce(self, v)

~\AnacondaNew\lib\site-packages\plotly\graph_objs\layout\_legend.py in __init__(self, arg, bgcolor, bordercolor, borderwidth, font, orientation,  tracegroupgap, traceorder, x, xanchor, y, yanchor, **kwargs)

~\AnacondaNew\lib\site-packages\plotly\basedatatypes.py in __setattr__(self, prop, value)

 ~\AnacondaNew\lib\site-packages\plotly\graph_objs\layout\_legend.py in bgcolor(self, val)

~\AnacondaNew\lib\site-packages\plotly\basedatatypes.py in __setitem__(self, prop, value)

~\AnacondaNew\lib\site-packages\plotly\basedatatypes.py in _set_prop(self, prop, val)

~\AnacondaNew\lib\site-packages\_plotly_utils\basevalidators.py in  validate_coerce(self, v, should_raise)

~\AnacondaNew\lib\site-packages\_plotly_utils\basevalidators.py in raise_invalid_val(self, v)

ValueError: 
Invalid value of type 'builtins.str' received for the 'bgcolor' property  of layout.legend
 Received value: 'pearl02'

The 'bgcolor' property is a color and may be specified as:
  - A hex string (e.g. '#ff0000')
  - An rgb/rgba string (e.g. 'rgb(255,0,0)')
  - An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
  - An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
  - A named CSS color:
        aliceblue, antiquewhite, aqua, aquamarine, azure,
        beige, bisque, black, blanchedalmond, blue,
        blueviolet, brown, burlywood, cadetblue,
        chartreuse, chocolate, coral, cornflowerblue,
        cornsilk, crimson, cyan, darkblue, darkcyan,
        darkgoldenrod, darkgray, darkgrey, darkgreen,
        darkkhaki, darkmagenta, darkolivegreen, darkorange,
        darkorchid, darkred, darksalmon, darkseagreen,
        darkslateblue, darkslategray, darkslategrey,
        darkturquoise, darkviolet, deeppink, deepskyblue,
        dimgray, dimgrey, dodgerblue, firebrick,
        floralwhite, forestgreen, fuchsia, gainsboro,
        ghostwhite, gold, goldenrod, gray, grey, green,
        greenyellow, honeydew, hotpink, indianred, indigo,
        ivory, khaki, lavender, lavenderblush, lawngreen,
        lemonchiffon, lightblue, lightcoral, lightcyan,
        lightgoldenrodyellow, lightgray, lightgrey,
        lightgreen, lightpink, lightsalmon, lightseagreen,
        lightskyblue, lightslategray, lightslategrey,
        lightsteelblue, lightyellow, lime, limegreen,
        linen, magenta, maroon, mediumaquamarine,
        mediumblue, mediumorchid, mediumpurple,
        mediumseagreen, mediumslateblue, mediumspringgreen,
        mediumturquoise, mediumvioletred, midnightblue,
        mintcream, mistyrose, moccasin, navajowhite, navy,
        oldlace, olive, olivedrab, orange, orangered,
        orchid, palegoldenrod, palegreen, paleturquoise,
        palevioletred, papayawhip, peachpuff, peru, pink,
        plum, powderblue, purple, red, rosybrown,
        royalblue, saddlebrown, salmon, sandybrown,
        seagreen, seashell, sienna, silver, skyblue,
        slateblue, slategray, slategrey, snow, springgreen,
        steelblue, tan, teal, thistle, tomato, turquoise,
        violet, wheat, white, whitesmoke, yellow,
        yellowgreen

我已经密谋导入,还将该程序包降级为2.7.0,但错误似乎相同。无法找到解决此问题的解决方案。am在anaconda发行版的jupyter笔记本中工作。 “ ValueError:     layout.legend的'bgcolor'属性收到的类型'builtins.str'的值无效      收到的值:'pearl02'“。

0 个答案:

没有答案