-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.py
More file actions
51 lines (40 loc) · 1.12 KB
/
default.py
File metadata and controls
51 lines (40 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
histogram-basic: Basic Histogram
Library: bokeh
"""
import numpy as np
from bokeh.io import export_png
from bokeh.plotting import figure
# Data - 500 normally distributed values (mean=100, std=15)
np.random.seed(42)
values = np.random.normal(100, 15, 500)
# Compute histogram bins
hist, edges = np.histogram(values, bins=30)
# Create figure (4800 x 2700 px for high resolution)
p = figure(width=4800, height=2700, title="Basic Histogram", x_axis_label="Value", y_axis_label="Frequency")
# Draw histogram using quad glyph
p.quad(
top=hist,
bottom=0,
left=edges[:-1],
right=edges[1:],
fill_color="#306998",
fill_alpha=0.7,
line_color="white",
line_width=1,
)
# Style title
p.title.text_font_size = "20pt"
p.title.align = "center"
# Style axis labels
p.xaxis.axis_label_text_font_size = "20pt"
p.yaxis.axis_label_text_font_size = "20pt"
p.xaxis.major_label_text_font_size = "16pt"
p.yaxis.major_label_text_font_size = "16pt"
# Style grid - subtle
p.xgrid.grid_line_alpha = 0.3
p.ygrid.grid_line_alpha = 0.3
# Ensure y-axis starts at zero
p.y_range.start = 0
# Save output
export_png(p, filename="plot.png")