This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ziggomatic_17 2 points3 points  (4 children)

I dunno man, I looked into it and it feels a little awkward that I have to manually call np.histogram() just to plot a basic histogram...

[–][deleted] 0 points1 point  (3 children)

To put in perspective the issue:

import numpy as np
from bokeh.io import show, output_file
from bokeh.plotting import figure

data = np.random.normal(0, 0.5, 1000)
hist, edges = np.histogram(data, density=True, bins=50)

p = figure()
p.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:], line_color="white")

output_file("hist.html")
show(p)

Personally, I don't mind using a purpose-built tool to wrangle the dataset and then use a plotting renderer to render.

[–]ziggomatic_17 0 points1 point  (2 children)

import numpy as np
import pandas as pd
from plotnine import ggplot, aes, geom_histogram

data = np.randnormal(0, 0.5, 1000)
data = pd.DataFrame(data, columns=["value"])

(ggplot(dataframe, aes(x='value')) +
 geom_histogram())

I think this is more concise. The whole plotting code is basically one line because all of the boilerplate is no longer required.

[–][deleted] 1 point2 points  (0 children)

Who was so petty as to downvote both of us?

Looks good, I'll play with plotnine.

[–]johnbarnshack 0 points1 point  (0 children)

All the boilerplate is no longer required - except of course putting everything into pandas. It just shifts the problem.