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 comentarios

darova
darova el 11 de Mzo. de 2020
Did you try plot() command?
Niklas
Niklas el 11 de Mzo. de 2020
Editada: Niklas el 11 de Mzo. de 2020
This would deliver me just a normal line plot?! And how could I even use the plot command with 3 arguments?
darova
darova el 11 de Mzo. de 2020
What do you mean by '3 arguments'? You want color line?
Niklas
Niklas el 11 de Mzo. de 2020
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 el 11 de Mzo. de 2020
Do you have example picture?
Niklas
Niklas el 12 de Mzo. de 2020
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 el 12 de Mzo. de 2020
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 el 12 de Mzo. de 2020
You are always welcome!
Niklas
Niklas el 13 de Mzo. de 2020
Editada: Niklas el 13 de Mzo. de 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

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Color and Styling en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 11 de Mzo. de 2020

Editada:

el 13 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by