Questions tagged [histogram2d]

131 questions
232
votes
13 answers

Generate a heatmap using a scatter data set

I have a set of X,Y data points (about 10k) that are easy to plot as a scatter plot but that I would like to represent as a heatmap. I looked through the examples in Matplotlib and they all seem to already start with heatmap cell values to generate…
greye
  • 8,921
  • 12
  • 41
  • 46
20
votes
1 answer

Please explain in detail 2D Histogram in Python

I am trying to understand what are the values of a 2D histogram. I have 2 numpy arrays of the same length X and Y (float numbers in each one). For example the first 10 values of X: [ 88, 193, 60, 98, 78, 100, 75, 76, 130] and Y: [ 18. , 9. , …
Steve
  • 241
  • 1
  • 3
  • 8
11
votes
1 answer

Creating a log-linear plot in matplotlib using hist2d

I was just wondering if this can be done. I have tried to set the bins explicitly using numpy logspace, and I have also tried to set the xscale to 'log'. Neither of these options work. Has anybody ever tried this? I just want a 2d histogram with a…
10
votes
1 answer

Make a 2D histogram with HEALPix pixellization using healpy

The data are coordinates of objects in the sky, for example as follows: import pylab as plt import numpy as np l = np.random.uniform(-180, 180, 2000) b = np.random.uniform(-90, 90, 2000) I want to do a 2D histogram in order to plot a map of the…
AlbertBranson
  • 405
  • 2
  • 7
9
votes
3 answers

How to bin a 2D array in numpy?

I'm new to numpy and I have a 2D array of objects that I need to bin into a smaller matrix and then get a count of the number of objects in each bin to make a heatmap. I followed the answer on this thread to create the bins and do the counts for a…
Mike T
  • 1,163
  • 1
  • 11
  • 27
7
votes
1 answer

"Too many values to unpack" in numpy histogram2d

I am using numpy histogram2d to compute the values for the visual representation of a 2d histogram of two variables: H, xedges, yedges = np.histogram2d(Z[:,0], Z[:,1], bins=100) where Z is a numpy matrix The error that I'm getting is: Traceback…
papafe
  • 2,959
  • 4
  • 41
  • 72
5
votes
3 answers

seaborn jointplot color by density

I am making 2d histograms for some data with millions of data points. matplotlib.hist2d(x,y,bins,norm=LogNorm()) works well and produces a plot in about 5 seconds, but I like the marginal histograms of seaborn.jointplot(). How do I color the points…
BML
  • 191
  • 2
  • 12
5
votes
3 answers

How to apply logarithmic axis labels without log scaling image (matplotlib imshow)

I have a large data set that is logarithmic in distribution. I want to make a heat map, so I do a 2D histogram and pass that to implot. Because the data is logarithmic, I am passing the log of the data to the histogram. When I make the plot,…
Alex
  • 427
  • 6
  • 12
5
votes
1 answer

3D histograms and Contour plots Python

I have a problem with contourf function of matplotlib. I have a txt data file from which I am importing my data. I have columns of data (pm1 and pm2) and I am performing a 2D histogram. I want to plot this data as a 3D histogram and as a contour…
Kilian A.G.
  • 123
  • 1
  • 6
5
votes
1 answer

Accounting for errors when creating a histogram

I have a set of N observations distributed as (x[i], y[i]), i=0..N points in a 2D space. Each point has associated errors in both coordinates (e_x[i], e_y[i], i=0..N) and also a weight attached to it (w[i], i=0..N). I'd like to generate a 2D…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
4
votes
3 answers

matplotlib and numpy - histogram bar color and normalization

So I have 2 problems: 1- I have a 2D histogram w/ 1D histograms along the x & y axes. These histograms total up their respective x and y values, while the main histogram totals the values in logarithmic x-y bins. The code is below. I've used…
earnric
  • 410
  • 4
  • 15
4
votes
2 answers

Make plt.colorbar extend to the steps immediately before and after vmin/vmax

I want to do something with plt.hist2d and plt.colorbar and I'm having real trouble working out how to do it. To explain, I've written the following example: import numpy as np from matplotlib import pyplot as plt x = np.random.random(1e6) y =…
John Coxon
  • 570
  • 1
  • 3
  • 15
4
votes
1 answer

np.histogram2D with fixed colour gradient

I am trying to modify an existing bit of python code that plots a heatmap of values using np.histogram2d. I am plotting several of these and I want the y-axis and the colour range to be comparable among them. I found out the way to manually set…
719016
  • 9,922
  • 20
  • 85
  • 158
4
votes
0 answers

How to create a histogram2d of two arrays of different lengths?

I am trying to create a numpy histogram2d for x and y where the sizes of x and y are different. From the documentation, x and y need to have the same size, but my data and the application I have naturally needs the histogram to have different x and…
newmathwhodis
  • 3,209
  • 2
  • 24
  • 26
3
votes
1 answer

Multiple 2D histogram on same plot

I have this script to extract data from an image and roi. I have everything working perfectly except the end when I output the graphs. Basically I'm having trouble with the windowing of both histograms. It doesn't matter if I change the gridsize,…
Courtney
  • 43
  • 3
1
2 3
8 9