问题
I want to add some css to part of my plot, (specifically, I want to set float:left).
How can I produce the plot within a div, so I can use css to control its layout?
For example, for code
def simple_plot(ax = None):
if ax is None:
fig, ax = plt.subplots()
a = [1,2,3,4]
b = [3,4,5,6]
plt.plot(a, b,'-', color='black')
simple_plot()
The default output html in Ipython Notebook is
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_png">
<img src="data:image/png;>
For some plots, I want to wrap it with a html/css, something like this:
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_png">
<div class="custom-css-for-matplotlib"> ## custom html/css code wrapper
How can I do that?
It would be fantastic if I can simply code in cell like:
<div class='custom css class'>
simple_plot()
</div>
来源:https://stackoverflow.com/questions/35425743/ipython-notebook-matplotlib-how-to-wrap-a-plot-within-a-html-div