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

darova
darova 2020년 3월 11일
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?
darova
darova 2020년 3월 11일
What do you mean by '3 arguments'? You want color line?
Niklas
Niklas 2020년 3월 11일
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.
darova
darova 2020년 3월 11일
Do you have example picture?
Niklas
Niklas 2020년 3월 12일
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.
Niklas
Niklas 2020년 3월 12일
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!
darova
darova 2020년 3월 12일
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에서 Color and Styling에 대해 자세히 알아보기

제품

태그

질문:

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