histogram2d

Creating a log-linear plot in matplotlib using hist2d

十年热恋 提交于 2019-12-04 05:14:15
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 log x-axis and a linear y-axis. Joe Kington The reason it's not working correctly is that plt.hist2d uses the pcolorfast method, which is much more efficient for large images, but doesn't support log axes. To have a 2D histogram that works correctly on log axes, you'll need to make it yourself using np.histogram2d and ax.pcolor . However, it's only

Please explain in detail 2D Histogram in Python

丶灬走出姿态 提交于 2019-12-04 02:43:57
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. , 36.1, 18.5, 34.3, 32.9, 32.2, 22. , 15. ] When I use: import matplotlib.pyplot as plt plt.hist2d(X,Y, bins=(10,20)) I get a 2D histogram. But what does it mean? 1D histogram simply shows me how much of each item I have. Please explain me what does it mean in 2D. Thanks in advance! Neo X Suppose you have a 1D array, you plot the position of its values on

Matplotlib stretches histogram2d vertically

倾然丶 夕夏残阳落幕 提交于 2019-12-02 05:27:52
问题 I'm using this code: fig = plt.figure(num=2, figsize=(8, 8), dpi=80, facecolor='w', edgecolor='k') x, y = [xy for xy in zip(*self.pulse_time_distance)] H, xedges, yedges = np.histogram2d(x, y, bins=(25, 25)) extent = [-50, +50, 0, 10] plt.imshow(H, extent=extent, interpolation='nearest') plt.colorbar() to produce a 2D histogram, however, the plot is stretched vertically and I simply can't figure out how to set its size properly: 回答1: Things are "stretched" because you're using imshow . By

Generate a heatmap in MatPlotLib using a scatter data set

家住魔仙堡 提交于 2019-11-26 00:15:36
问题 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 the image. Is there a method that converts a bunch of x,y, all different, to a heatmap (where zones with higher frequency of x,y would be \"warmer\")? 回答1: If you don't want hexagons, you can use numpy's histogram2d function: import numpy as np