2d color plots

5 views (last 30 days)
Niklas
Niklas on 11 Mar 2020
Edited: Niklas on 13 Mar 2020
Hello everybody,
Iam a matlab beginner and I would like to plot a 2d plot with a colorbar in matlab.
I have examined displacements per atom (just a physical quantity) within a cylindrical accelerator target (radius r, thickness d). The values are binned in length (z direction, thickness) and radial. For both, the same bin number was applied. So, actually I would like to have a plot which shows the physical quantity as a function of the target depth at the x-axis and the radius at the y-axis in the form of colored pixels. The number of pixels should equal bin*bin, means if radius and length are binned with 20 bins both there should be 400 pixels with a color in the sum.
What is the easiest way to plot that? In which form as .txt would I have to load the data in? One single .txt file or several?
I would be very thankful for answers, I was not able to find an answer which helps me.
Kind regards,
Niklas
  9 Comments
darova
darova on 12 Mar 2020
You are always welcome!
Niklas
Niklas on 13 Mar 2020
Edited: Niklas on 13 Mar 2020
Well, one further question has arised. The "pixels" are not placed with its center in the middle of the bin size, but rather at the corrsepsonding x value, example:
My x axis goes from 0 to 0.5 in steps of 0.1. The first value (corresponding to x=0) is set at 0 with its center and not at 0.05, so the bin goes from -0.05 to 0.05. This is misleading. My maximum value of the x axis (0.5) does not get displayed then, if I change the range of x axis to xmax=0.5 cm then there is a white border, means it is not filled with any color.
Below you find a picture of my plot, same problem arised for the y axis, you can see that there is a shift beyond the 0 values and x=0.5 cm is not depicted. Any ideas how one can solve that issue as easy as possible?
Another question may be, how I could get something like a pink above the dark blue, since the contrast is not so good. I tried to play with the colormap in the figure window, but it was unsatisfying for me.
With kind regards and thanks for the help,
Niklas

Sign in to comment.

Answers (0)

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!