2D plot with colormap

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

2D plot with colormap

guido.bonalumi
Hi everyone!
I am trying to plot some fields (velocity and pressure fields) using the colormap option. The results is quite good but I need help for some improvements.
Here is my code:
cd output
data_U = csvread('U_2014_10_05.csv');
cd ..

X_min = min(data_U(:,1));
X_max = max(data_U(:,1));
Y_min = min(data_U(:,2));
Y_max = max(data_U(:,2));

data_U(:,1) = data_U(:,1) - X_min;
data_U(:,2) = data_U(:,2) - Y_min;

Xi = linspace(0,X_max-X_min,1000);
Yi = linspace(0,Y_max-Y_min,1000);

[XX YY]=meshgrid(Xi,Yi);

Ui = griddata(data_U(:,1), data_U(:,2), data_U(:,3), XX, YY);

map=jet(16);
colormap (map);
surf(XX,YY,Ui);
shading interp;

#title("Vista frontale");
#xlabel("x");
#ylabel("y");

axis ('off', "image");
colorbar("EastOutside");

#set(gca, 'XGrid', 'off');
#set(gca, 'YGrid', 'off');

#caxis("auto");
caxis([0 93.6]);

view(2)
print -color velocita_2014_10_05.eps


My issues are:
1. The colorbar overlaps the graph even if I used the "EastOutside" option. Why?
2. Is it possible to have the maximum value (93.6) shown on the top of the colorbar?
3. Is it possible to add, instead of the two classical axis, a small reference system in the lower left corner? Something like the small set of arrows that usually show up in the lower left corner in Paraview (for the ones who are familiar with it). Maybe without color, just with black arrows and the labels for the 3 directions (x, y and z).
4. The graph is good but not correct at the moment and I need to exclude some values:
    - The values inside the blade (all zeros) so the blade will be white as the outside of the channel.
    - The values outside the pressure side of the channel: they are not real, but they have been created by the interpolation. I do not understand why only there and not outside the suction side for example (look at the two images attached for a better understanding of the problem).
actual result
wanted result

Can anybody help me? Thanks in advance!
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

Doug Stewart-4


On Sun, Oct 12, 2014 at 9:45 AM, guido.bonalumi <[hidden email]> wrote:
Hi everyone!
I am trying to plot some fields (velocity and pressure fields) using the
colormap option. The results is quite good but I need help for some
improvements.
Here is my code:
/cd output
data_U = csvread('U_2014_10_05.csv');
cd ..

X_min = min(data_U(:,1));
X_max = max(data_U(:,1));
Y_min = min(data_U(:,2));
Y_max = max(data_U(:,2));

data_U(:,1) = data_U(:,1) - X_min;
data_U(:,2) = data_U(:,2) - Y_min;

Xi = linspace(0,X_max-X_min,1000);
Yi = linspace(0,Y_max-Y_min,1000);

[XX YY]=meshgrid(Xi,Yi);

Ui = griddata(data_U(:,1), data_U(:,2), data_U(:,3), XX, YY);

map=jet(16);
colormap (map);
surf(XX,YY,Ui);
shading interp;

#title("Vista frontale");
#xlabel("x");
#ylabel("y");

axis ('off', "image");
colorbar("EastOutside");

#set(gca, 'XGrid', 'off');
#set(gca, 'YGrid', 'off');

#caxis("auto");
caxis([0 93.6]);

view(2)
print -color velocita_2014_10_05.eps/

My issues are:
1. The colorbar overlaps the graph even if I used the "EastOutside" option.
Why?
2. Is it possible to have the maximum value (93.6) shown on the top of the
colorbar?
3. Is it possible to add, instead of the two classical axis, a small
reference system in the lower left corner? Something like the small set of
arrows that usually show up in the lower left corner in Paraview (for the
ones who are familiar with it). Maybe without color, just with black arrows
and the labels for the 3 directions (x, y and z).
4. The graph is good but not correct at the moment and I need to exclude
some values:
    - The values inside the blade (all zeros) so the blade will be white as
the outside of the channel.
    - The values outside the pressure side of the channel: they are not
real, but they have been created by the interpolation. I do not understand
why only there and not outside the suction side for example (look at the two
images attached for a better understanding of the problem).
<http://octave.1599824.n4.nabble.com/file/n4666931/velocita.jpg>
<http://octave.1599824.n4.nabble.com/file/n4666931/velocita2.jpg>

Can anybody help me? Thanks in advance!



Tell us what version of Octave and what OS.
 
-- 


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
Octave 3.6.1 on Ubuntu 12.04 LTS 64 bit. Sorry!
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

Doug Stewart-4


On Sun, Oct 12, 2014 at 10:24 AM, guido.bonalumi <[hidden email]> wrote:
Octave 3.6.1 on Ubuntu 12.04 LTS 64 bit. Sorry!



--
View this message in context: http://octave.1599824.n4.nabble.com/2D-plot-with-colormap-tp4666931p4666933.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave


Using 3.8.1  the color bar is to the side.
I think you should upgrade.
--
DASCertificate for 206392


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
Ok I will upgrade as soon as I can (I am upgrading TexLive right now).
Meanwhile any idea to solve the other problems? In particular the last one, which is quite tricky.
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
This post was updated on .
I have updated Octave to the latest version (3.8.1) and this is the result:
actual result
Honestly this result is even worst than the previous one! The colorbar still overlaps the graph and now its scale is less detailed.
The code is still the same, why do I get this poor result?
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

Juan Pablo Carbajal-2


On Sun, Oct 12, 2014 at 6:52 PM, guido.bonalumi <[hidden email]> wrote:
I have updated Octave to the latest version (3.8.1) and this is the result:
<http://octave.1599824.n4.nabble.com/file/n4666938/velocita3.jpg>
Honestly this result is even worst than the previous one! The colorbar still
overlaps the graph and now the its scale is less detailed.
The code is still the same, why do I get this poor result?



--
View this message in context: http://octave.1599824.n4.nabble.com/2D-plot-with-colormap-tp4666931p4666938.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

What is the output of graphics_toolkit?

Have you tried 
    close all
    graphics_toolkit("gnuplot")
and then plot again?
What about "fltk"? (I think that is the default).


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
Actually I do not know what are you talking about!
Unfortunately I am not so expert. I tried adding the two lines that you suggested but I still have the same result, with the colorbar that overlaps the graph. The only difference is that the scale now is more detailed.
I do not know anything about graphics_toolkit, do you have some documentation that I can read?
Anyway, later I will have to export this graph with matlab2tikz because I have to use it in LaTex. Will this graphics_toolkit option have some effects on this conversion somehow?
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

bpabbott
Administrator
In reply to this post by guido.bonalumi

> On Oct 12, 2014, at 9:45 AM, guido.bonalumi <[hidden email]> wrote:
>
> Hi everyone!
> I am trying to plot some fields (velocity and pressure fields) using the
> colormap option. The results is quite good but I need help for some
> improvements.
> Here is my code:
> /cd output
> data_U = csvread('U_2014_10_05.csv');

Can you make "U_2014_10_05.csv" available for us to download?

That way we can determine if the problem still exists in the latest development sources, and can also (more efficiently) try fixing the problem for you.

Ben
_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
Of course! Here it is:
U_2014_10_05.csv
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
I was trying this small code that was written for me by a friend of mine:

clc
close all
clear all

cd output
a=csvread('U_2014_10_05.csv');
cd ..

x=a(:,1);
y=a(:,2);
z=a(:,3);

scatter3(x(:),y(:),z(:),[],z(:));
colormap(jet(16));
shading interp
colorbar;

It was written it for Matlab, and running it with Octave I receive this error:

'invalid error for color property "markeredgecolor"'

The error is referred to this line:

scatter3(x(:),y(:),z(:),[],z(:));

but I checked and the syntax seems right to me. Do you know some possible cause to this error?
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

Juan Pablo Carbajal-2


On Wed, Oct 15, 2014 at 1:06 PM, guido.bonalumi <[hidden email]> wrote:
I was trying this small code that was written for me by a friend of mine:

clc
close all
clear all

cd output
a=csvread('U_2014_10_05.csv');
cd ..

x=a(:,1);
y=a(:,2);
z=a(:,3);

scatter3(x(:),y(:),z(:),[],z(:));
colormap(jet(16));
shading interp
colorbar;

It was written it for Matlab, and running it with Octave I receive this
error:

'invalid error for color property "markeredgecolor"'

The error is referred to this line:

scatter3(x(:),y(:),z(:),[],z(:));

but I checked and the syntax seems right to me. Do you know some possible
cause to this error?



--
View this message in context: http://octave.1599824.n4.nabble.com/2D-plot-with-colormap-tp4666931p4666966.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

Does this works?
x = rand(16,1);
y = rand(16,1);
z = rand(16,1);
scatter3(x(:),y(:),z(:),[],z(:));

If not, what version of Octave? What is the output of graphics_toolkit?

If I execute the rest of the code then I get an error, but a different one.


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
ok I did some tests on my 2 PCs:

1) First test:
PC: 1, the one that gave me the problem
Octave version: 3.6.1
graphics_toolkit: gnuplot
result: your code works, there is a little error on the y axis because the values rapresented on the scale overlap all on the first value, but the graph is ok

2) Second test:
PC: 2
Octave version: 3.8.1
graphics_toolkit: fltk
result: your code works and the y axis scale's values now are fine. My code doesn't work! A window appears but there is no graph inside, and nothing else happens neither an error.

3) Second test:
PC: 2
Octave version: 3.8.1
graphics_toolkit: gnuplot
result: your code works but there is the same error with the y axis as in the first case. My code doesn't work! Nothing happens!
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

Doug Stewart-4


On Wed, Oct 15, 2014 at 8:18 AM, guido.bonalumi <[hidden email]> wrote:
ok I did some tests on my 2 PCs:

1) First test:
PC: 1, the one that gave me the problem
Octave version: 3.6.1
graphics_toolkit: gnuplot
result: your code works, there is a little error on the y axis because the
values rapresented on the scale overlap all on the first value, but the
graph is ok

2) Second test:
PC: 2
Octave version: 3.8.1
graphics_toolkit: fltk
result: your code works and the y axis scale's values now are fine. My code
doesn't work! A window appears but there is no graph inside, and nothing
else happens neither an error.

3) Second test:
PC: 2
Octave version: 3.8.1
graphics_toolkit: gnuplot
result: your code works but there is the same error with the y axis as in
the first case. My code doesn't work! Nothing happens!



--
View this message in context: http://octave.1599824.n4.nabble.com/2D-plot-with-colormap-tp4666931p4666971.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave


I tried the code:

x = rand(16,1);
y = rand(16,1);
z = rand(16,1);
scatter3(x(:),y(:),z(:),[],z(:));

and it works correctly here.

ubuntu 14.04 and octave 3.8.1  graphics_toolkit('fltk')    and with graphics_toolkit( 'gnuplot')

Doug

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
I checked again, adding this to lines just to have an output:

view(2)
print -color prova.eps

and your code works fine, the output file (prova.eps) is ok, even the y axis. I do not understand why my code is not working.
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

Doug Stewart-4


On Wed, Oct 15, 2014 at 9:16 AM, guido.bonalumi <[hidden email]> wrote:
I checked again, adding this to lines just to have an output:

view(2)
print -color prova.eps

and your code works fine, the output file (prova.eps) is ok, even the y
axis. I do not understand why my code is not working.




Are you asking about the results of the print command, or the results on the plot window????
Doug
 

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
Sorry but I do not understand your question. What I see in my .eps file and what I see in the plot window should be the same. Am I right?
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

Doug Stewart-4


On Wed, Oct 15, 2014 at 9:56 AM, guido.bonalumi <[hidden email]> wrote:
Sorry but I do not understand your question. What I see in my .eps file and
what I see in the plot window should be the same. Am I right?



Yes it should be but the eps does use some more software so to trouble shoot your problem I was just asking if they are the same.


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

guido.bonalumi
Ok now I understand. I added the two lines to the code suggested by Juan Pablo. With his code the .eps file is fine so it means that is just a problem of visualization in the plot window.
Adding the two lines at my code is useless because it crashes when the plot window shows up. The window is empty and the code seems to be stuck.
Reply | Threaded
Open this post in threaded view
|

Re: 2D plot with colormap

Doug Stewart-4


On Wed, Oct 15, 2014 at 10:13 AM, guido.bonalumi <[hidden email]> wrote:
Ok now I understand. I added the two lines to the code suggested by Juan
Pablo. With his code the .eps file is fine so it means that is just a
problem of visualization in the plot window.
Adding the two lines at my code is useless because it crashes when the plot
window shows up. The window is empty and the code seems to be stuck.





Let us go 1 step at a time does this code 'crash' octave?
x = rand(16,1);
y = rand(16,1);
z = rand(16,1);
scatter3(x(:),y(:),z(:),[],z(:));


I just had a new idea.

Did you wait long enough for the data to be processed? 
You have a large data set and it will take a long time to get drawn.
The time obviously depends on the speed of your machine etc.

Doug 

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
12