[Scilab-users] issue with xs2png

classic Classic list List threaded Threaded
7 messages Options
der_Phil der_Phil
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] issue with xs2png

Dear all,

I am building a figure with 4 subplots.

Now since I want to have a title in the figure I can use several options to set a title on the figure.

Currently I use

subplot(221);
plot(...)
a1 = gca();
a1.title.Text = "my title";

However so far I understand, the title position is somehow bound to the axis settings.
such as: if xmin xMax yMin yMax are changing the position of the title also changes
.

Now: I need to have the title position independend of the axis settings.
A way of doing this is using a uicontrol in the "text"-format style.

Drawback: xs2png does not seem to save the uicontrol to the image....at least the title build with uicontrol does not appear in the PNG-file.

Any hint?

Thank you,
Phil


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: issue with xs2png

Hello P M
(Prime Minister ?)

Le 25/02/2019 à 17:10, P M a écrit :
Dear all,

I am building a figure with 4 subplots.

Now since I want to have a title in the figure I can use several options to set a title on the figure.

Currently I use

subplot(221);
plot(...)
a1 = gca();
a1.title.Text = "my title";

However so far I understand, the title position is somehow bound to the axis settings.
such as: if   xmin xMax yMin yMax are changing the position of the title also changes.
Now: I need to have the title position independend of the axis settings.

What do you mean? The position of the title can be explicitly set with

title("My title", "position",[xtitle, ytitle])


where the coordinates [xtitle, ytitle] are given in data scale.

Using this,  a1.title.auto_position is turned "off", and the position that you set should remain independent of any changes of data bounds.
Isn't it the case?

HTH
Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
der_Phil der_Phil
Reply | Threaded
Open this post in threaded view
|

Re: issue with xs2png

no...I'm not (yet) prime minister :-))

What do I mean? Please, check this small example:

clear();
clc;
xdel();
x = linspace(1,10);
y = x .* x;
f1 = figure();
f1.background = 8;
title ('my title','position',[10 100]);
subplot(221);
plot(x,y);
a1 = gca();
a1.data_bounds = [0,0;10,100];
a1.tight_limits = ["on","on","off"];

so far so good.
change to:     a1.data_bounds = [0,0;10,200];
You see that the title position changes.

I need to play with a1.data_bounds.
This is because my diagram representes data from a file and each file content may change the Y-axis...so I can not have a fixed value for a1.data_bound.

I probably could figure out how to set the Y-position of the title with respect to max(y).
I just thought it is quite nice, if the position of the title would be depending on just the figure size and not on the axis scale.

Cheers, Philipp








Am Mo., 25. Feb. 2019 um 17:26 Uhr schrieb Samuel Gougeon <[hidden email]>:
Hello P M
(Prime Minister ?)

Le 25/02/2019 à 17:10, P M a écrit :
Dear all,

I am building a figure with 4 subplots.

Now since I want to have a title in the figure I can use several options to set a title on the figure.

Currently I use

subplot(221);
plot(...)
a1 = gca();
a1.title.Text = "my title";

However so far I understand, the title position is somehow bound to the axis settings.
such as: if   xmin xMax yMin yMax are changing the position of the title also changes.
Now: I need to have the title position independend of the axis settings.

What do you mean? The position of the title can be explicitly set with

title("My title", "position",[xtitle, ytitle])


where the coordinates [xtitle, ytitle] are given in data scale.

Using this,  a1.title.auto_position is turned "off", and the position that you set should remain independent of any changes of data bounds.
Isn't it the case?

HTH
Samuel

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
der_Phil der_Phil
Reply | Threaded
Open this post in threaded view
|

Re: issue with xs2png

...just checked: even with adding:     a1.title.auto_position = 'off';
...same thing

Am Mo., 25. Feb. 2019 um 20:37 Uhr schrieb P M <[hidden email]>:
no...I'm not (yet) prime minister :-))

What do I mean? Please, check this small example:

clear();
clc;
xdel();
x = linspace(1,10);
y = x .* x;
f1 = figure();
f1.background = 8;
title ('my title','position',[10 100]);
subplot(221);
plot(x,y);
a1 = gca();
a1.data_bounds = [0,0;10,100];
a1.tight_limits = ["on","on","off"];

so far so good.
change to:     a1.data_bounds = [0,0;10,200];
You see that the title position changes.

I need to play with a1.data_bounds.
This is because my diagram representes data from a file and each file content may change the Y-axis...so I can not have a fixed value for a1.data_bound.

I probably could figure out how to set the Y-position of the title with respect to max(y).
I just thought it is quite nice, if the position of the title would be depending on just the figure size and not on the axis scale.

Cheers, Philipp








Am Mo., 25. Feb. 2019 um 17:26 Uhr schrieb Samuel Gougeon <[hidden email]>:
Hello P M
(Prime Minister ?)

Le 25/02/2019 à 17:10, P M a écrit :
Dear all,

I am building a figure with 4 subplots.

Now since I want to have a title in the figure I can use several options to set a title on the figure.

Currently I use

subplot(221);
plot(...)
a1 = gca();
a1.title.Text = "my title";

However so far I understand, the title position is somehow bound to the axis settings.
such as: if   xmin xMax yMin yMax are changing the position of the title also changes.
Now: I need to have the title position independend of the axis settings.

What do you mean? The position of the title can be explicitly set with

title("My title", "position",[xtitle, ytitle])


where the coordinates [xtitle, ytitle] are given in data scale.

Using this,  a1.title.auto_position is turned "off", and the position that you set should remain independent of any changes of data bounds.
Isn't it the case?

HTH
Samuel

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Title in normalized coordinates <= Re: issue with xs2png

In reply to this post by der_Phil
Le 25/02/2019 à 20:37, P M a écrit :
no...I'm not (yet) prime minister :-))

What do I mean? Please, check this small example:

clear();
clc;
xdel();
x = linspace(1,10);
y = x .* x;
f1 = figure();
f1.background = 8;
title ('my title','position',[10 100]);
subplot(221);
plot(x,y);
a1 = gca();
a1.data_bounds = [0,0;10,100];
a1.tight_limits = ["on","on","off"];

so far so good.
change to:     a1.data_bounds = [0,0;10,200];
You see that the title position changes.

I need to play with a1.data_bounds.
This is because my diagram representes data from a file and each file content may change the Y-axis...so I can not have a fixed value for a1.data_bound.

I probably could figure out how to set the Y-position of the title with respect to max(y).
I just thought it is quite nice, if the position of the title would be depending on just the figure size and not on the axis scale.

Thanks for the context. It often helps.
Here is a suggestion:
clf
subplot(1,2,2)
ax1 = gca();
x = linspace(-2,7,100);
plot(x, sin)

axt = newaxes();
axt.axes_bounds = ax1.axes_bounds;
plotframe([0 0 1 1]);
set(axt, "box", "off", "margins",[0 0 0 0],"axes_visible","off","filled","off")
title("My title in normalized coodinates", "position",[0.2 0.9],"fontsize",4)

sca(ax1);

Here, it's possible to control the normalization reference. This example uses
the entry area as the reference area. So it can be a subarea, not the whole figure.
But you can set it to the whole figure (or uicontrol frame) if you think it more handy.

HTH
Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Title in normalized coordinates <= Re: issue with xs2png

Le 25/02/2019 à 21:14, Samuel Gougeon a écrit :
Le 25/02/2019 à 20:37, P M a écrit :
no...I'm not (yet) prime minister :-))

What do I mean? Please, check this small example:

clear();
clc;
xdel();
x = linspace(1,10);
y = x .* x;
f1 = figure();
f1.background = 8;
title ('my title','position',[10 100]);
subplot(221);
plot(x,y);
a1 = gca();
a1.data_bounds = [0,0;10,100];
a1.tight_limits = ["on","on","off"];

so far so good.
change to:     a1.data_bounds = [0,0;10,200];
You see that the title position changes.

I need to play with a1.data_bounds.
This is because my diagram representes data from a file and each file content may change the Y-axis...so I can not have a fixed value for a1.data_bound.

I probably could figure out how to set the Y-position of the title with respect to max(y).
I just thought it is quite nice, if the position of the title would be depending on just the figure size and not on the axis scale.

Thanks for the context. It often helps.
Here is a suggestion:
clf
subplot(1,2,2)
ax1 = gca();
x = linspace(-2,7,100);
plot(x, sin)

axt = newaxes();
axt.axes_bounds = ax1.axes_bounds;
plotframe([0 0 1 1]);
set(axt, "box", "off", "margins",[0 0 0 0],"axes_visible","off","filled","off")
title("My title in normalized coodinates", "position",[0.2 0.9],"fontsize",4)

sca(ax1);


Using title() instead of xstring() does not allow to center the title on its middle.
Then, the title is badly shifted when resizing the windows.
A better solution follows:

clf
subplot(1,2,2)
ax1 = gca();
x = linspace(-2,7,100);
plot(x, sin)

axt = newaxes();
axt.axes_bounds = ax1.axes_bounds;
plotframe([0 0 1 1]);
set(axt, "box", "off", "margins",[0 0 0 0],"axes_visible","off","filled","off")
xstring(0.5,0.93, "My title in normalized coordinates")
t = gce();
set(t,"text_box_mode","centered","font_size",4);

sca(ax1);



Samuel



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
der_Phil der_Phil
Reply | Threaded
Open this post in threaded view
|

Re: Title in normalized coordinates <= Re: issue with xs2png

That should do.
Thank you.

Am Mo., 25. Feb. 2019 um 21:24 Uhr schrieb Samuel Gougeon <[hidden email]>:
Le 25/02/2019 à 21:14, Samuel Gougeon a écrit :
Le 25/02/2019 à 20:37, P M a écrit :
no...I'm not (yet) prime minister :-))

What do I mean? Please, check this small example:

clear();
clc;
xdel();
x = linspace(1,10);
y = x .* x;
f1 = figure();
f1.background = 8;
title ('my title','position',[10 100]);
subplot(221);
plot(x,y);
a1 = gca();
a1.data_bounds = [0,0;10,100];
a1.tight_limits = ["on","on","off"];

so far so good.
change to:     a1.data_bounds = [0,0;10,200];
You see that the title position changes.

I need to play with a1.data_bounds.
This is because my diagram representes data from a file and each file content may change the Y-axis...so I can not have a fixed value for a1.data_bound.

I probably could figure out how to set the Y-position of the title with respect to max(y).
I just thought it is quite nice, if the position of the title would be depending on just the figure size and not on the axis scale.

Thanks for the context. It often helps.
Here is a suggestion:
clf
subplot(1,2,2)
ax1 = gca();
x = linspace(-2,7,100);
plot(x, sin)

axt = newaxes();
axt.axes_bounds = ax1.axes_bounds;
plotframe([0 0 1 1]);
set(axt, "box", "off", "margins",[0 0 0 0],"axes_visible","off","filled","off")
title("My title in normalized coodinates", "position",[0.2 0.9],"fontsize",4)

sca(ax1);


Using title() instead of xstring() does not allow to center the title on its middle.
Then, the title is badly shifted when resizing the windows.
A better solution follows:

clf
subplot(1,2,2)
ax1 = gca();
x = linspace(-2,7,100);
plot(x, sin)

axt = newaxes();
axt.axes_bounds = ax1.axes_bounds;
plotframe([0 0 1 1]);
set(axt, "box", "off", "margins",[0 0 0 0],"axes_visible","off","filled","off")
xstring(0.5,0.93, "My title in normalized coordinates")
t = gce();
set(t,"text_box_mode","centered","font_size",4);

sca(ax1);



Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users