IDL Histograms: Solving the X-Axis Frustration

  • Thread starter Thread starter taylrl3
  • Start date Start date
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 5K views
taylrl3
Messages
60
Reaction score
0
Hi,

I am currently having an absolute nightmare trying to use the histogram command in IDL. I almost have it as I want, I just want it to show my units on the x-axis rather than the number of bins. I can't find anything that explains how this works on the net it seems no one really understands it at all. Hopefully someone here can help me. This is how I am plotting it at the moment:

plot, histogram(Galaxydiffs, bin=((max-min)/nbins)), xtitle='X/h!u-1!nMpc', psym=10

Galaxydiffs is an array with the data I want in the histogram.
nbins is the number of bins

Currently the x-axis is the number of bins. I want it to show the distances corresponding to each bin.

Any help would be most appreciated as this is driving me crazy

Thanks
Taylrl2
 
Physics news on Phys.org


Hi Taylrl2,

I understand your frustration with trying to use the histogram command in IDL. It can be tricky to get the x-axis to display the units you want, but it is definitely possible.

First, make sure that your Galaxydiffs array contains the actual distances you want to plot on the x-axis. If it does not, you will need to convert your data to the desired units before plotting.

Next, you can use the "bin" keyword in the histogram command to specify the bins you want to use. Instead of providing the number of bins, you can provide an array of the bin edges you want to use. For example, if your data ranges from 0 to 10 Mpc and you want 10 bins, you can use the following command:

plot, histogram(Galaxydiffs, bin=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), xtitle='X/h!u-1!nMpc', psym=10

This will create 10 bins with the corresponding distances on the x-axis.

Alternatively, you can use the "range" keyword to specify the range of your data and the number of bins you want, and IDL will automatically calculate the bin edges for you. For example:

plot, histogram(Galaxydiffs, range=[0, 10], nbins=10), xtitle='X/h!u-1!nMpc', psym=10

I hope this helps to solve your issue with the histogram command. If you continue to have trouble, please provide more information about your data and the specific error message you are receiving.

Best of luck!