2d color plots

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 个评论

Did you try plot() command?
Niklas
Niklas 2020-3-11
编辑:Niklas 2020-3-11
This would deliver me just a normal line plot?! And how could I even use the plot command with 3 arguments?
What do you mean by '3 arguments'? You want color line?
I want a color coded plot, no line. I have my physical quantity, which is a function of the radius and the depth. It was evaluated in a binned form. I want something like a color intensity contour plot.
Do you have example picture?
Source: N. Demir et al., Application of FLUKA code to gamma-ray attenuation, energy deposition and dose calculations, International Journal of Radiation Research 2017, Volume 15
This one is what I mean in principle.
I have found a solution on my own now, here is my solution:
x=dlmread('x.txt');
y=dlmread('y.txt');
z=dlmread('z.txt');
imagesc(x,y,z);
colormap jet
cb = colorbar('vert');
zlab = get(cb,'ylabel');
set(zlab,'String','Labeling');
This works quite well and gives me what I wanted. Thanks for your help so far!
You are always welcome!
Niklas
Niklas 2020-3-13
编辑:Niklas 2020-3-13
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

请先登录,再进行评论。

回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Red 的更多信息

产品

标签

提问:

2020-3-11

编辑:

2020-3-13

Community Treasure Hunt

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

Start Hunting!

Translated by