Reputation: 21
II am using bokeh and would like to have logaritmic xaxis using Line of bokeh.charts. But impiossible. It is possible with basic glyphs and figure (bokeh.plotting) but not for Chart. any idea? Or did I miss something?
Here is the code :
import bokeh.models
import bokeh.plotting
import pandas as pd</br>
from bokeh.plotting import figure, show, output_file
from bokeh.layouts import column, row
from bokeh.charts import Line
plot=Line(df,x='x',y='y',x_axis_type='log')
output_file("cycling.html",title="cycling TOP")
layout=row(plot)
show(layout)
And here is the log: AttributeError: unexpected attribute 'x_axis_type' to Chart, similar attributes are x_mapper_type
Thks. David
Upvotes: 1
Views: 994
Reputation: 3123
Here there is an example using Line
from bokeh.charts
to create a line with the x axis in logarithmic scale:
import pandas as pd
from bokeh.plotting import show, output_file
from bokeh.layouts import row
from bokeh.charts import Line
import numpy as np
x = np.logspace(0,2,100)
d = {'x': x, 'y': 1/(20**2+x**2)**0.5}
df = pd.DataFrame(data=d)
plot=Line(df,x = 'x',y='y',x_mapper_type='log')
output_file("cycling.html",title="cycling TOP")
layout=row(plot)
show(layout)
Output:
Upvotes: 2