Questions tagged [histogram2d]
131 questions
3
votes
1 answer
How do I create curved bins in matplotlib polar 2D histogram?
I am plotting a polar 2d histogram in Python 3.7 using matplotlib and the following code (adapted from this answer to another question):
import numpy as np
import matplotlib.pyplot as plt
# input data
azimut = np.random.rand(3000)*2*np.pi
radius =…

samwalton3
- 33
- 5
3
votes
1 answer
Compute mean value per pixel using weighted 2d histogram
I am using pyplot.hist2d to plot a 2D histogram (x vs.y) weighted by a third variable, z. Instead of summing z values in a given pixel [x_i,y_i] as done by hist2d, I'd like to obtain the average z of all data points falling in that pixel.
Is there a…

Nuanda
- 75
- 7
3
votes
2 answers
define breaks for hist2d in R
is there a simple way to define breaks instead of nbins for a 2d histogram (hist2d) in R?
I want to define the range for the x- and yaxis for a 2D histogram and the number of bins for each dimension.
My example:
# example data
x <- sample(-1:100,…

AnjaFanti
- 31
- 4
2
votes
1 answer
How can I generate 2D histogram with my customized bins?
I am a physicist studying about super-galactic objects and I feel like it is difficult to make 2D histogram based on what I want to make.
To avoid confusion and getting answer what I already know. I will show two method which I already know and then…

Kyle
- 80
- 4
2
votes
1 answer
numpy digitize for 2 dimensional histogram
I am searching for the np.digitize function for bi-dimensional histogram.
From these lines of code:
H, xedges, yedges = np.histogram2d(coord[:, 0], coord[:, 1])
H = H.T
print(H)
I obtain the following histogram:
[[ 7. 20. 16. 14. 10. …

Python
- 359
- 2
- 16
2
votes
1 answer
How to align two numpy histograms so that they share the same bins/index, and also transform histogram frequencies to probabilities?
How to convert two datasets X and Y to histograms whose x-axes/index are identical, instead of the x-axis range of variable X being collectively lower or higher than the x-axis range of variable Y (like how the code below generates)? I would like…

develarist
- 1,224
- 1
- 13
- 34
2
votes
1 answer
Interacting with histogram colorbars in physt polar_map
Using the physt library you can create a polar histogram of data that automatically returns a colorbar, such as:
from physt.histogram_nd import Histogram2D
# Histogram2D([radian_bins, angular_bins], [histogram values for given bins])
hist =…

gartont
- 23
- 3
2
votes
1 answer
Why is binned_statistic_2d now throwing TypeError?
I have been using scipy's binned_statistic_2d function to plot a 2d histogram of some data, particularly to return a list of the index of which bin the data is in, by setting the expand_binnumbers = True. It was working perfectly, until today. The…

shadowbiscuit
- 218
- 1
- 8
2
votes
1 answer
Return the frequency in a bin of a 2D histogram in Julia
Suppose I have some 2D data points, and using the Plots package in Julia, a 2D histogram can be easily plotted. My task is to define a function that maps between a data point to the frequency of data points of the bin to which that point belongs to.…

Sato
- 1,013
- 1
- 12
- 27
2
votes
2 answers
How to do a matshow or imshow, but display the axis values as bin boundaries (i.e as you would on a 2d frequency/density plot)
I need to do a 2d density-like plot. However I calculate the "densities" myself. So essentially I have an NxM array of values that I can only plot with plt.matshow (or imshow).
fig, ax = plt.subplots()
im =…

Marses
- 1,464
- 3
- 23
- 40
2
votes
1 answer
Plot with 2D histograms bins
I have seen in posts Normalizing histogram bins in Gnuplot that is possible to bin some x samples and plot a histogram, with
binwidth=5
bin(x,width)=width*floor(x/width) + binwidth/2.0
plot 'file.dat' using (bin($1,…

user1993416
- 698
- 1
- 9
- 28
2
votes
0 answers
Difference (or quotient) between two 2D (not 1D) histograms (not KDEs) plotted using R and ggplot2?
Similar questions have been asked in the past, but I haven't been satisfied with any of the answers and none matches what I require. I believe the problem has been that the questions have been ambiguously posed. I'll try to do better.
Imagine that…

Dr. Andrew John Lowe
- 510
- 8
- 20
2
votes
1 answer
add semi-transparency to 2d histogram
I am trying to make a plot like this one:
I want a 2D histogram with bar color proportional to the height and semi-transparent bars.
I tried to put together the examples provided here
x = randn(100, 2);
figure
hist3(x, [20 20]);
colormap(hot) %…

shamalaia
- 2,282
- 3
- 23
- 35
2
votes
0 answers
How to put the number of elements inside each cell of the stat_summary2d plot in ggplot?
I have generated following 2D plot to show how the mean of z variable (z_mean) changes with variables x and y :
Code to generate the above figure is below:
test = data.frame(group = factor(c(rep(1, 100), rep(2, 100), rep(3, 100))),
x =…

gruangly
- 942
- 8
- 13
2
votes
1 answer
Altering height range of matplotlib histogram2d
I am trying to plot some 2D empirical probability distributions using matplotlib's histogram2d. I want the colours to be on the same scale across several different plots, but cannot find a way to set a scale even if I know a global upper and lower…

Daniel Johnson
- 238
- 3
- 11