Search code examples
pythonsvgsavebokeh

python bokeh saving issue and label disappear, and display problem


As I am aiming to plot the data into the plot, I encounter 2 problems.

(1) For the Bokeh function, while I am plotting 4 pictures in a row and adding the save as the SVG. Then the browser is shown as figure1. Moreover, as I comment out the code below, it work definitely right as I thought. It's weird.

p1.output_backend = "svg"
export_svgs(p1, filename="./number_like_comment/fig/{}.svg".format(action_str))

enter image description here enter image description here

(2) For the second question, after I save those files, I realized that the "Label" I put in the plot also disappear. (as figure3).

enter image description here

Thanks so much for reading through. This question bother me quite a long time.


Solution

  • I guess that the data (on the x-axis) starts at 0, and on a logaxis for some reason the svg renderer doesn't like that and refuses to draw the entire line. The canvas renderer (used for the interactive plots) only refuses to draw the line-segment going from or to 0.

    If you want to keep the logarithmic axis, you can either remove the 0 values or replace them by something which can be displayed in a logarithmic scale (e.g. 0.1) and then fixate the x-axis.