IDL Histograms: Solving the X-Axis Frustration

  • Thread starter Thread starter taylrl3
  • Start date Start date
AI Thread Summary
The discussion revolves around difficulties using the histogram command in IDL, specifically the challenge of displaying units on the x-axis instead of the number of bins. The user, Taylrl2, seeks assistance in modifying their plot to reflect actual distances corresponding to each bin. A helpful response suggests ensuring that the data array, Galaxydiffs, contains the correct distance values. It recommends using the "bin" keyword to specify an array of bin edges directly, allowing for precise control over the x-axis labels. Alternatively, the "range" keyword can be employed to define the data range and automatically calculate bin edges. This guidance aims to resolve the user's frustration with the histogram plotting process in IDL.
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
 
Technology 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!
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Back
Top