How to increase the height of the graph? The graphs are square in google colab, regardless of the values of x and y.
Do you mean make the actual plot canvas physically taller (i.e. more centimeters on the screen)? If so, then figure
accepts a height
parameter for that (values in pixels).
But that height has nothing to do with the data (“x and y”) so perhaps you mean how to make the extents of the y-axis range larger? By default, Bokeh will auto-range to accommodate all you data, so if that’s not happening, it’s probably because you explicitly overrode the axis range.
It’s not possible to speculate further without clarification of your question and a complete Minimal Reproducible Example of your code.
Simply you can put height=35 like that width=25px
Refer the below code .It will helpful for you.
import xyzservices.providers as xyz
import pandas as pd
from bokeh.plotting import figure, show
from bokeh.layouts import column, row
from bokeh.models import ColumnDataSource,DataTable,TableColumn, HoverTool
from bokeh.sampledata.stocks import AAPL
from math import pi
from bokeh.palettes import Category20c
from bokeh.transform import cumsum
# prepare some data
x = [1, 2, 3, 4, 5]
y1 = [6, 7, 2, 4, 5]
y2 = [2, 3, 4, 5, 6]
y3 = [4, 5, 5, 7, 2]
# create a new plot with a title and axis labels
p = figure(title="Multiple line example", x_axis_label="x-axis", y_axis_label="y-axis")
p.title_location = "left"
p.title.text_font_size = "25px"
p.title.align = "right"
p.title.background_fill_color = "darkgrey"
p.title.text_color = "white"
q = figure(title="chart",x_axis_label="x-axis", y_axis_label="y-axis")
q.title_location = "left"
q.title.text_font_size = "25px"
q.title.align = "right"
q.title.background_fill_color = "darkgrey"
q.title.text_color = "white"
# add multiple renderers
p.line(x, y1, legend_label="Temp.", color="blue", line_width=2)
p.line(x, y2, legend_label="Rate", color="red", line_width=2)
p.line(x, y3, legend_label="Objects", color="green", line_width=2)
p.circle(x, y3, legend_label="Objects", color="#bb5566", size=16)
q.vbar(x=x, top=y2, legend_label="Rate", width=0.5, bottom=0, color="red")
r = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
x_axis_type="mercator", y_axis_type="mercator")
r.add_tile(xyz.OpenStreetMap.Mapnik)
x = {
'United States': 157,
'United Kingdom': 93,
'Japan': 89,
'China': 63,
'Germany': 44,
'India': 42,
'Italy': 40,
'Australia': 35,
'Brazil': 32,
'France': 31,
'Taiwan': 31,
'Spain': 29,
}
data = pd.Series(x).reset_index(name='value').rename(columns={'index': 'country'})
data['angle'] = data['value']/data['value'].sum() * 2*pi
data['color'] = Category20c[len(x)]
pie = figure(height=350, title="Pie Chart",
tooltips="@country: @value", x_range=(-0.5, 1.0))
pie.wedge(x=0, y=1, radius=0.4,
start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),
line_color="white", fill_color='color', legend_field='country', source=data)
pie.axis.axis_label = None
pie.axis.visible = False
pie.grid.grid_line_color = None
pie.toolbar.autohide = True
df = pd.DataFrame(AAPL)
stats = df.describe().reset_index()
source = ColumnDataSource(stats)
columns = [TableColumn(field=col,title=col) for col in stats.columns]
data_table = DataTable(source=source,columns=columns,width=1000,height=700,editable=True)
source_bar = ColumnDataSource(df)
db = figure(title="Bar Chart", x_axis_label="Index", y_axis_label="High")
bar =db.vbar(x='index', top='high', source=source_bar, width=5, color="red")
hover = HoverTool(renderers=[bar], tooltips=[("Index", "@index"), ("High", "@high")])
db.add_tools(hover)
column_layout = column(p, q, r, pie)
row_layout = row (data_table,db)
final_layout =column(column_layout,row_layout)
# show the results
show(final_layout)