histogram2d

Altering height range of matplotlib histogram2d

限于喜欢 提交于 2021-02-05 09:11:41
问题 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 bound on the resulting distribution. As is, each color scale will run from the minimum height to the maximum height of the histogram bins, but this range will be different for each plot. One potential solution would be to force one bin to take the

How to align two numpy histograms so that they share the same bins/index, and also transform histogram frequencies to probabilities?

天涯浪子 提交于 2020-12-13 04:25:38
问题 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 the numpy histogram output values to be ready to plot in a shared histogram-plot afterwards. import numpy as np from numpy.random import randn n = 100 # number of bins #datasets X = randn(n)*.1 Y = randn(n)*.2 #empirical distributions a = np

Make a 2D histogram with HEALPix pixellization using healpy

这一生的挚爱 提交于 2020-08-01 07:00:47
问题 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 density of some point with (l, b) coordinates in the sky, using HEALPix pixellization on Mollweide projection. How can I do this using healpy ? The tutorial: http://healpy.readthedocs.io/en/v1.9.0/tutorial.html says how to plot a 1D array, or a fits

Controlling scatterhist Marker Transparency

走远了吗. 提交于 2019-12-25 01:16:49
问题 I need to control the transparency of the markers in the figure produced with the scatterhist command in MATLAB. The following post is helpful in handling the color of the histograms: Controlling scatterhist bar colors. How can the transparency of the markers be modified? How can I add a contour plot on top of the markers? 回答1: tl;dr : In MATLAB R2019a, scatterhist can do contours but it is difficult (yet possible) to add marker transparency, and scatterhistogram can easily do transparency

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

余生长醉 提交于 2019-12-24 00:57:52
问题 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, however, I want the axis to be restored (ie 10^hist bin values) and log axes. If I set the axis to log style, then the image looks all skewed. The data is already 'logged' from when I passed it to the histogram, so I don't want the image affected, just

Pandas/Python: 2D histogram fails with value error

强颜欢笑 提交于 2019-12-11 12:54:52
问题 I am trying to create a 2D histrogram from a Pandas data frame "rates" The X and Y axis are supposed to be transforms from the dataframe, i.e., the X and Y axis are 'scaled' from the original frame columns and the bin heigths are according to the number of hits in each x/y bin. import numpy, pylab, pandas import matplotlib.pyplot as plt list(rates.columns.values) ['sizes', 'transfers', 'positioning'] x=(rates["sizes"]/1024./1024.) y=((rates["sizes"]/rates["transfers"])/1024.)+rates[

Creating a log-linear plot in matplotlib using hist2d

*爱你&永不变心* 提交于 2019-12-09 17:51:56
问题 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. 回答1: 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

Please explain in detail 2D Histogram in Python

微笑、不失礼 提交于 2019-12-09 16:13:28
问题 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

Build up and plot Matplotlib 2d histogram in polar coordinates using the Legendre Polynomials

家住魔仙堡 提交于 2019-12-08 06:27:48
问题 I am attempting to plot a distribution: This is the temperature distribution inside of a sphere of radius (a) whose upper hemisphere is held at T=1 and lower hemisphere is held at T=0 (ignore the discontinuity at the boundary between the two hemispheres) and P_l are the Legendre polynomials of the first kind. import pylab as pl from scipy.special import eval_legendre as Leg import math,sys def sumTerm(a,r,theta,l): """ Compute term of sum given radius of sphere (a), y and z coordinates, and

define breaks for hist2d in R

我是研究僧i 提交于 2019-12-06 04:49:51
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, 2000, replace=T) y <- sample(0:89, 2000, replace=T) # create 2d histogram h2 <- hist2d(x,y,nbins=c(23,19),xlim=c(-1,110), ylim=c(0,95),xlab='x',ylab='y',main='hist2d') This results in this 2D histogram output 1 ---------------------------- 2-D Histogram Object ---------------------------- Call: hist2d(x = x, y = y, nbins = c(23, 19), xlab = "x", ylab