I have a list of Pandas dataframes stored in dfs and I am plotting a grid (three columns) of histograms:
hists = [Histogram(dfs[colname],
title=colname,
bins=20,
) for colname in dfs.columns]
for h in hists:
h.x_range = Range1d(-20, 20)
ncol = 3
hists = [hists[i:i+ncol] for i in range(0,len(hists),ncol)]
p = gridplot(hists)
However, I’ve noticed that while the number of bins (20) are the same in all of the plots, the width and location of each bin is inconsistent from plot to plot. I believe this is because each plot has a different x_range and the bins are generated using some optimized method. Instead, I’d like to be able to specify the width and location of each bin, maybe in the form of a list of tuples or something:
You can’t specify the width and location of the bins with Histogram chart. I suggest you to add a github issue with this feature request so we can have a discussion and better understanding of what is needed and if we can plan on doing it. As a side note, we have many improvements in mind for the Charts interface and one of these is to make it possible (and hopefully easy) to specify custom binning function to Histogram. This MAY related to your needs.
I have a list of Pandas dataframes stored in dfs and I am plotting a grid (three columns) of histograms:
hists = [Histogram(dfs[colname],
title=colname,
bins=20,
) for colname in dfs.columns]
for h in hists:
h.x_range = Range1d(-20, 20)
ncol = 3
hists = [hists[i:i+ncol] for i in range(0,len(hists),ncol)]
p = gridplot(hists)
However, I’ve noticed that while the number of bins (20) are the same in all of the plots, the width and location of each bin is inconsistent from plot to plot. I believe this is because each plot has a different x_range and the bins are generated using some optimized method. Instead, I’d like to be able to specify the width and location of each bin, maybe in the form of a list of tuples or something:
Is there a way to accomplish this with bar charts instead?
···
On Tuesday, December 22, 2015 at 12:22:00 PM UTC-5, Fabio Pliger wrote:
Hi,
You can’t specify the width and location of the bins with Histogram chart. I suggest you to add a github issue with this feature request so we can have a discussion and better understanding of what is needed and if we can plan on doing it. As a side note, we have many improvements in mind for the Charts interface and one of these is to make it possible (and hopefully easy) to specify custom binning function to Histogram. This MAY related to your needs.
I have a list of Pandas dataframes stored in dfs and I am plotting a grid (three columns) of histograms:
hists = [Histogram(dfs[colname],
title=colname,
bins=20,
) for colname in dfs.columns]
for h in hists:
h.x_range = Range1d(-20, 20)
ncol = 3
hists = [hists[i:i+ncol] for i in range(0,len(hists),ncol)]
p = gridplot(hists)
However, I’ve noticed that while the number of bins (20) are the same in all of the plots, the width and location of each bin is inconsistent from plot to plot. I believe this is because each plot has a different x_range and the bins are generated using some optimized method. Instead, I’d like to be able to specify the width and location of each bin, maybe in the form of a list of tuples or something:
It may be possible, but probably would require some effort.
You would need to pre calculate the histogram values as one column, then the other column would have the categorical locations (labels) for where the bar should go. I’m not sure how it would handle the numerical data that represents the bar centers.
···
On Tuesday, December 22, 2015 at 11:33:17 AM UTC-6, [email protected] wrote:
Is there a way to accomplish this with bar charts instead?
On Tuesday, December 22, 2015 at 12:22:00 PM UTC-5, Fabio Pliger wrote:
Hi,
You can’t specify the width and location of the bins with Histogram chart. I suggest you to add a github issue with this feature request so we can have a discussion and better understanding of what is needed and if we can plan on doing it. As a side note, we have many improvements in mind for the Charts interface and one of these is to make it possible (and hopefully easy) to specify custom binning function to Histogram. This MAY related to your needs.
I have a list of Pandas dataframes stored in dfs and I am plotting a grid (three columns) of histograms:
hists = [Histogram(dfs[colname],
title=colname,
bins=20,
) for colname in dfs.columns]
for h in hists:
h.x_range = Range1d(-20, 20)
ncol = 3
hists = [hists[i:i+ncol] for i in range(0,len(hists),ncol)]
p = gridplot(hists)
However, I’ve noticed that while the number of bins (20) are the same in all of the plots, the width and location of each bin is inconsistent from plot to plot. I believe this is because each plot has a different x_range and the bins are generated using some optimized method. Instead, I’d like to be able to specify the width and location of each bin, maybe in the form of a list of tuples or something:
So, I was able to use bar charts by first rounding my “label” column to the nearest integer and then doing:
p = Bar(dfs, label=‘rounded’, values=‘A’, agg=‘count’, legend=‘top_right’)
show(p)
However, the labeled column ‘rounded’ has values between (-11, 11) and I can’t find a way to set the axis to be between (-20, 20). Any suggestion?
···
On Tuesday, December 22, 2015 at 1:15:34 PM UTC-5, Nick Roth wrote:
It may be possible, but probably would require some effort.
You would need to pre calculate the histogram values as one column, then the other column would have the categorical locations (labels) for where the bar should go. I’m not sure how it would handle the numerical data that represents the bar centers.
On Tuesday, December 22, 2015 at 11:33:17 AM UTC-6, [email protected] wrote:
Is there a way to accomplish this with bar charts instead?
On Tuesday, December 22, 2015 at 12:22:00 PM UTC-5, Fabio Pliger wrote:
Hi,
You can’t specify the width and location of the bins with Histogram chart. I suggest you to add a github issue with this feature request so we can have a discussion and better understanding of what is needed and if we can plan on doing it. As a side note, we have many improvements in mind for the Charts interface and one of these is to make it possible (and hopefully easy) to specify custom binning function to Histogram. This MAY related to your needs.
I have a list of Pandas dataframes stored in dfs and I am plotting a grid (three columns) of histograms:
hists = [Histogram(dfs[colname],
title=colname,
bins=20,
) for colname in dfs.columns]
for h in hists:
h.x_range = Range1d(-20, 20)
ncol = 3
hists = [hists[i:i+ncol] for i in range(0,len(hists),ncol)]
p = gridplot(hists)
However, I’ve noticed that while the number of bins (20) are the same in all of the plots, the width and location of each bin is inconsistent from plot to plot. I believe this is because each plot has a different x_range and the bins are generated using some optimized method. Instead, I’d like to be able to specify the width and location of each bin, maybe in the form of a list of tuples or something: