Changing tick label colour in mpld3

I am trying to plot stuff using matplotlib and mpld3. This is the code I use to generate my graph:

_fig = plt.figure()
_pl = _fig.add_subplot(111)
_pl.plot(_times, _values)
_pl.set_xlabel("Time")
_pl.set_ylabel("Value")

_pl.tick_params(direction="out", axis="both", colors="white", which="both")
_pl.xaxis.label.set_color("white")
_pl.yaxis.label.set_color("white")

_data = mpld3.fig_to_html(_fig)
.... send to client to be rendered

A graph is created and all the dynamic controls work. "Time" and "Value" labels get printed in white but tick labels in black.

If I skip mpld3 and test it with plt.show(), all tick labels get printed in white. When I check the javascript code generated by mpld3, I do not seem to detect the colour setting there for tick labels.

If I use another parameter, like font size, in tick_params it does have an effect. Only the colour gets ignored, which causes the labels to be printed in black on a dark blue background.

How do I change this?

Edit:

When inspecting the actual page rendered, there seems to be a "fill" property that determines the colour.

div#fig_el249691400950908834083380374260 .mpld3-xaxis text 
{font-family:sans-serif; font-size:10px; fill:black; stroke:none; }

I tried overriding this in css but I could not figure out how to do it. This seems to override whatever I set elsewhere. It appears mpld3 sets the colour of the tick label, but how do I modify this?

Hannu


mpld3 only supports a subset of matplotlib's full capabilities, and tick formatting is one of the many things that is not yet supported. There is a partial list of these missing features on the mpld3 wiki.

链接地址: http://www.djcxy.com/p/37912.html

上一篇: 创建黑色背景演示文稿幻灯片的情节

下一篇: 更改mpld3中的刻度线标签颜色