[Scilab-users] Export plot from figure with uicontrols

classic Classic list List threaded Threaded
20 messages Options
Iza Iza
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Export plot from figure with uicontrols

Hello,

I know that there's no official method to export a figure containing
uicontrols but I need to export only my plot which is in the frame of
the figure. Ordinary print screen is not enough because I may need a
bigger size of a picture and also an .eps file. Do you have any other
method to do this?

Kind regards,
Iza
_______________________________________________
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: Export plot from figure with uicontrols

Le 26/02/2019 à 15:15, Izabela Wójcik-Grząba a écrit :
> Hello,
>
> I know that there's no official method to export a figure containing
> uicontrols but I need to export only my plot which is in the frame of
> the figure. Ordinary print screen is not enough because I may need a
> bigger size of a picture

The saved screenshot has the size of the figure when you save it. So:

plot2d()
set(gcf(), "visible","off","axes_size",[2440,1840]); // for instance
xs2png(0, "bigfig.png")

// winopen("bigfig.png")

should do what you expect.

> and also an .eps file.

PostScript is a vectorial format. So the rendering from it should be
scalable according to your requirements.

Samuel

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

Re: Export plot from figure with uicontrols

But my problem is that in my figure appart from my plot I have different
uicontrols, so when I use one of the xs2... commands it gives me a blank
picture.

Iza




W dniu 26.02.2019 17:07, Samuel Gougeon napisał(a):

> Le 26/02/2019 à 15:15, Izabela Wójcik-Grząba a écrit :
>> Hello,
>>
>> I know that there's no official method to export a figure containing
>> uicontrols but I need to export only my plot which is in the frame of
>> the figure. Ordinary print screen is not enough because I may need a
>> bigger size of a picture
>
> The saved screenshot has the size of the figure when you save it. So:
>
> plot2d()
> set(gcf(), "visible","off","axes_size",[2440,1840]); // for instance
> xs2png(0, "bigfig.png")
>
> // winopen("bigfig.png")
>
> should do what you expect.
>
>> and also an .eps file.
>
> PostScript is a vectorial format. So the rendering from it should be
> scalable according to your requirements.
>
> 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
|

Re: Export plot from figure with uicontrols

Le 26/02/2019 à 17:13, Izabela Wójcik-Grząba a écrit :
> But my problem is that in my figure appart from my plot I have
> different uicontrols, so when I use one of the xs2... commands it
> gives me a blank picture.

Aa. I would try to turn all uicontrols.visible="off", and then try xs2##().
However, I am pretty sure that it will fail.
Otherwise, you may destroy them just for saving the remaining figure.

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

Re: Export plot from figure with uicontrols

In reply to this post by Samuel GOUGEON

Izabela,

I've had the same problem. Saving as eps is theoretically the solution
but I couldn't manage to make it compatible with, for instance, Word. My
solution has been to save the figure as svg (a vectorized format), then
open it with GIMP, a free open source image editor, then select an
appropriate size (large enough so that when inserted in a word
processing software has a very high, printable resolution) and save as
high quality jpg. If the export contains things you don't want, you
simple trim out those parts.

Regards,

Federico Miyara


On 26/02/2019 13:07, Samuel Gougeon wrote:

> Le 26/02/2019 à 15:15, Izabela Wójcik-Grząba a écrit :
>> Hello,
>>
>> I know that there's no official method to export a figure containing
>> uicontrols but I need to export only my plot which is in the frame of
>> the figure. Ordinary print screen is not enough because I may need a
>> bigger size of a picture
>
> The saved screenshot has the size of the figure when you save it. So:
>
> plot2d()
> set(gcf(), "visible","off","axes_size",[2440,1840]); // for instance
> xs2png(0, "bigfig.png")
>
> // winopen("bigfig.png")
>
> should do what you expect.
>
>> and also an .eps file.
>
> PostScript is a vectorial format. So the rendering from it should be
> scalable according to your requirements.
>
> Samuel
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>
>


---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus

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

Re: Export plot from figure with uicontrols

In reply to this post by Samuel GOUGEON

> Otherwise, you may destroy them just for saving the remaining figure.

It is an idea, but how to do it properly?
My figure contains to frames. In one of them there are some checkboxes
which change the visibility of some parts of the plot. The plot is in
the second frame. I would like to keep the changes made by checkboxes in
the exported version of the plot.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Iza Iza
Reply | Threaded
Open this post in threaded view
|

Re: Export plot from figure with uicontrols

In reply to this post by fmiyara
Thanks Federico, but as I wrote in an answer to Samuel, the problem is
that you can't export a figure with uicontrols because you get a blank
picture.



W dniu 26.02.2019 17:34, Federico Miyara napisał(a):

> Izabela,
>
> I've had the same problem. Saving as eps is theoretically the solution
> but I couldn't manage to make it compatible with, for instance, Word.
> My solution has been to save the figure as svg (a vectorized format),
> then open it with GIMP, a free open source image editor, then select
> an appropriate size (large enough so that when inserted in a word
> processing software has a very high, printable resolution) and save as
> high quality jpg. If the export contains things you don't want, you
> simple trim out those parts.
>
> Regards,
>
> Federico Miyara
>
>
> On 26/02/2019 13:07, Samuel Gougeon wrote:
>> Le 26/02/2019 à 15:15, Izabela Wójcik-Grząba a écrit :
>>> Hello,
>>>
>>> I know that there's no official method to export a figure containing
>>> uicontrols but I need to export only my plot which is in the frame of
>>> the figure. Ordinary print screen is not enough because I may need a
>>> bigger size of a picture
>>
>> The saved screenshot has the size of the figure when you save it. So:
>>
>> plot2d()
>> set(gcf(), "visible","off","axes_size",[2440,1840]); // for instance
>> xs2png(0, "bigfig.png")
>>
>> // winopen("bigfig.png")
>>
>> should do what you expect.
>>
>>> and also an .eps file.
>>
>> PostScript is a vectorial format. So the rendering from it should be
>> scalable according to your requirements.
>>
>> Samuel
>>
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.scilab.org/mailman/listinfo/users
>>
>>
>
>
> ---
> El software de antivirus Avast ha analizado este correo electrónico en
> busca de virus.
> https://www.avast.com/antivirus
>
> _______________________________________________
> 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
|

Re: Export plot from figure with uicontrols

In reply to this post by Iza
Le 26/02/2019 à 17:37, Izabela Wójcik-Grząba a écrit :
>
>> Otherwise, you may destroy them just for saving the remaining figure.
>
> It is an idea, but how to do it properly?
> My figure contains to frames. In one of them there are some checkboxes
> which change the visibility of some parts of the plot. The plot is in
> the second frame. I would like to keep the changes made by checkboxes
> in the exported version of the plot.

What do you mean by "frames"? made with uicontrol(), or with subplot()
(or xsetech())?

The graphical effect of a uicontrol's callback remains after deleting
the uicontrol.
But to change it, you will have to regenerate the figure, choose another
action, delete all uicontrols, and save the new version of your figure.

If all uicontrol are set as direct children of the figure, deleting all
of them in a once could be done with something like
c = gcf().children;
delete(c(c.type=="uicontrol"))

Samuel

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

Re: Export plot from figure with uicontrols

In reply to this post by Iza

Izabela,

Oh, I see... no idea for now...

Federico


On 26/02/2019 13:41, Izabela Wójcik-Grząba wrote:
Thanks Federico, but as I wrote in an answer to Samuel, the problem is that you can't export a figure with uicontrols because you get a blank picture.



W dniu 26.02.2019 17:34, Federico Miyara napisał(a):
Izabela,

I've had the same problem. Saving as eps is theoretically the solution
but I couldn't manage to make it compatible with, for instance, Word.
My solution has been to save the figure as svg (a vectorized format),
then open it with GIMP, a free open source image editor, then select
an appropriate size (large enough so that when inserted in a word
processing software has a very high, printable resolution) and save as
high quality jpg. If the export contains things you don't want, you
simple trim out those parts.

Regards,

Federico Miyara


On 26/02/2019 13:07, Samuel Gougeon wrote:
Le 26/02/2019 à 15:15, Izabela Wójcik-Grząba a écrit :
Hello,

I know that there's no official method to export a figure containing uicontrols but I need to export only my plot which is in the frame of the figure. Ordinary print screen is not enough because I may need a bigger size of a picture

The saved screenshot has the size of the figure when you save it. So:

plot2d()
set(gcf(), "visible","off","axes_size",[2440,1840]); // for instance
xs2png(0, "bigfig.png")

// winopen("bigfig.png")

should do what you expect.

and also an .eps file.

PostScript is a vectorial format. So the rendering from it should be scalable according to your requirements.

Samuel

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




---
El software de antivirus Avast ha analizado este correo electrónico en
busca de virus.
https://www.avast.com/antivirus

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




Libre de virus. www.avast.com

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

Re: Export plot from figure with uicontrols

In reply to this post by Samuel GOUGEON
> What do you mean by "frames"? made with uicontrol(), or with subplot()
> (or xsetech())?

They are made with uicontrol().

> The graphical effect of a uicontrol's callback remains after deleting
> the uicontrol.

Ok, it is good.

> If all uicontrol are set as direct children of the figure, deleting
> all of them in a once could be done with something like
> c = gcf().children;
> delete(c(c.type=="uicontrol"))

But in my case I would also delete my plot which is in one of the two
frames.
The structure is like that:
Figure has two uicontrols Frame; first Frame has Axes (my plot, which I
would like to export),second Frame has another uicontrol Frame which has
7 uicontrols Checkbox
I hope it's clear :-)

Iza
_______________________________________________
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: Export plot from figure with uicontrols

Le 26/02/2019 à 18:32, Izabela Wójcik-Grząba a écrit :
What do you mean by "frames"? made with uicontrol(), or with subplot()
(or xsetech())?

They are made with uicontrol().

The graphical effect of a uicontrol's callback remains after deleting
the uicontrol.

Ok, it is good.

If all uicontrol are set as direct children of the figure, deleting
all of them in a once could be done with something like
c = gcf().children;
delete(c(c.type=="uicontrol"))

But in my case I would also delete my plot which is in one of the two frames.
The structure is like that:
Figure has two uicontrols Frame; first Frame has Axes (my plot, which I would like to export),second Frame has another uicontrol Frame which has 7 uicontrols Checkbox
I hope it's clear :-)

As the exportation result, it is too clear, unfortunately.

When exporting, you get a blank figure because the exportation removes all uicontrol.
Since your plot in on one of them (the frame), it is removed with its "substrate".

I don't think it will be possible to save your plots on uicontrol frames with Scilab.
But you may use subplot() and/or xsetech() to set the layout of the figure.
Why are you using a uicontrol frame?



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

Re: Export plot from figure with uicontrols

In reply to this post by Iza

Izabela,

I've just tried what I suggested and obtained a good figure.

Steps:

1) Run the following example (or any other)

t
= 0:0.01:2*%pi;
x
= sin(t);
figure
(1, 'BackgroundColor', [1,1,1]);
scf
(1)
clf

plot(t,x)
h=uicontrol("style","pushbutton","string","$x^2$");

This is the Scilab oputput




Note the button at the bottom left


2) On the figure window:

File / Export to... / SVG Image / Save

3) Run GIMP 2.8 (I guess any version works, I use a portable one from PortableApps, no need to install)

File / Open
Locate the path and file name
Open
A rendering dialog appears.
Select the desired X and Y size (by default they are linked to preserve aspect ratio). You can also apply a multiplier (I first used 5x to get high resolution, but the example below is with 1x to avoid email bouncing)
The image apears
Export
Apply a .jpg extension
Choose a folder
Export

This is what I get

Note the UI button is gone. The image above is not high resolution because there is a limit of 100 kb for this list, but with 5x the image occupies onli 227 kb and is truly high resolution. If you like I can send privately the 5x version so you can check. There is no limit to the attainable rtesolution (other than memory issues, I guess).

Federico


On 26/02/2019 13:41, Izabela Wójcik-Grząba wrote:
Thanks Federico, but as I wrote in an answer to Samuel, the problem is that you can't export a figure with uicontrols because you get a blank picture.



W dniu 26.02.2019 17:34, Federico Miyara napisał(a):
Izabela,

I've had the same problem. Saving as eps is theoretically the solution
but I couldn't manage to make it compatible with, for instance, Word.
My solution has been to save the figure as svg (a vectorized format),
then open it with GIMP, a free open source image editor, then select
an appropriate size (large enough so that when inserted in a word
processing software has a very high, printable resolution) and save as
high quality jpg. If the export contains things you don't want, you
simple trim out those parts.

Regards,

Federico Miyara


On 26/02/2019 13:07, Samuel Gougeon wrote:
Le 26/02/2019 à 15:15, Izabela Wójcik-Grząba a écrit :
Hello,

I know that there's no official method to export a figure containing uicontrols but I need to export only my plot which is in the frame of the figure. Ordinary print screen is not enough because I may need a bigger size of a picture

The saved screenshot has the size of the figure when you save it. So:

plot2d()
set(gcf(), "visible","off","axes_size",[2440,1840]); // for instance
xs2png(0, "bigfig.png")

// winopen("bigfig.png")

should do what you expect.

and also an .eps file.

PostScript is a vectorial format. So the rendering from it should be scalable according to your requirements.

Samuel

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




---
El software de antivirus Avast ha analizado este correo electrónico en
busca de virus.
https://www.avast.com/antivirus

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




Libre de virus. www.avast.com

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

Re: Export plot from figure with uicontrols

In reply to this post by Iza
Dear Izabela,

I had the same problem when working with GUI containing various control and
plot frame. Eventually, I found the solution.
The solution consists in copying of the axes handle from the frame to a
newly created figure.
For example, in my case, I have the following GUI
<http://mailinglists.scilab.org/file/t496664/GUI.png>
Next, I get the handle to this graphics axes:

//It should be an axes entity          
pl = findobj("Tag", "plot_1"); // It is a good idea to assign tag to your
axes when you create a GUI

and copy it to a new figure:

fig = scf();

copy(pl, fig.children);

which result in the same separate figure, which can easily be converted to a
graphics file:
<http://mailinglists.scilab.org/file/t496664/test.png>




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Iza Iza
Reply | Threaded
Open this post in threaded view
|

Re: Export plot from figure with uicontrols

Samuel, Federico, Oleksiy,
Thank you a lot for your feedback. I will check your ideas and find out
which will be the best for me.

> Why are you using a uicontrol frame?

Samuel, the reason is simple. When I created the code for this figure
about a year ago I was a real beginner in Scilab so I utilized one of
the examples from Scilab.org.

Iza

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

Re: {EXT} Re: Export plot from figure with uicontrols

In reply to this post by fmiyara
Hello,

Concerning the following point (which is not related to Scilab):

> I couldn't manage to make it compatible with, for instance, Word.
> My solution has been to save the figure as svg (a vectorized format),
> then open it with GIMP

You'd better open the SVG with Inkscape (also free)
then save as .emf.

EMF (enhanced metafile) is a Microsoft Windows vector graphic format,
you can thus have the vector graphic quality inside Microsoft Word.

There are some limitations to EMF
but as long as you only have curves, colour surfaces and texts
it should be OK.

Regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

Public
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
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: Export plot from figure with uicontrols

Hello,

Le 28/02/2019 à 09:26, Dang Ngoc Chan, Christophe a écrit :

> Hello,
>
> Concerning the following point (which is not related to Scilab):
>
>> I couldn't manage to make it compatible with, for instance, Word.
>> My solution has been to save the figure as svg (a vectorized format),
>> then open it with GIMP
> You'd better open the SVG with Inkscape (also free)
> then save as .emf.
>
> EMF (enhanced metafile) is a Microsoft Windows vector graphic format,
> you can thus have the vector graphic quality inside Microsoft Word.
>
> There are some limitations to EMF
> but as long as you only have curves, colour surfaces and texts
> it should be OK.

It's possible to export Scilab graphics directly in EMF format with
xs2emf() since Scilab 5.5.0.
I have never used it, but it's available.

Regards
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: Export plot from figure with uicontrols

Le 28/02/2019 à 20:45, Samuel Gougeon a écrit :
Hello,

.../...
It's possible to export Scilab graphics directly in EMF format with xs2emf() since Scilab 5.5.0.
I have never used it, but it's available.

When using xs2emf() with Scilab 6.0.2 on Windows7, a (modal) error occurs (*)

--> xs2emf(0,"Figure_0.emf")
xs2emf: Unable to create export file, permission denied.


but anyway, the file is well created and can be actually imported in a document. It works!

Samuel

(*) we saw this error when preparing the 6.0.2 release, but forgot to report it.
It's being done.


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

Re: {EXT} Re: Export plot from figure with uicontrols

In reply to this post by Christophe Dang Ngoc Chan

Christophe,

One can also export as EMF directly from Scilab, the problem is that it is not compatible with Word 2003 (the version I have). Do you mean that the EMF produced by Inkscape is really compatible with Word? If this is the case, there is something to be improved in the Scilab EMF export.

Regards,

Federico Miyara


On 28/02/2019 05:26, Dang Ngoc Chan, Christophe wrote:
Hello,

Concerning the following point (which is not related to Scilab):

I couldn't manage to make it compatible with, for instance, Word.
My solution has been to save the figure as svg (a vectorized format),
then open it with GIMP
You'd better open the SVG with Inkscape (also free)
then save as .emf.

EMF (enhanced metafile) is a Microsoft Windows vector graphic format,
you can thus have the vector graphic quality inside Microsoft Word.

There are some limitations to EMF
but as long as you only have curves, colour surfaces and texts
it should be OK.

Regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

Public
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



Libre de virus. www.avast.com

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

Re: {EXT} Re: Export plot from figure with uicontrols

Hello,

> De : users [mailto:[hidden email]] De la part de
> Federico Miyara Envoyé : vendredi 1 mars 2019 04:20
>
> Do you mean that the EMF produced by Inkscape is really compatible with Word?

I do. I regularly produce sketches with Inkscape and export them as .emf to include them in .docx fles (at work, I use Microsoft Word 2013).

> If this is the case, there is something to be improved in the Scilab EMF export.

I never used it but probably.

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

Public
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
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: {EXT} Re: Export plot from figure with uicontrols

In reply to this post by fmiyara
Hello Federico,

Le 01/03/2019 à 04:19, Federico Miyara a écrit :

Christophe,

One can also export as EMF directly from Scilab, the problem is that it is not compatible with Word 2003 (the version I have). Do you mean that the EMF produced by Inkscape is really compatible with Word? If this is the case, there is something to be improved in the Scilab EMF export.

I have not Word 2003, but i have done the following, and it works:

* create a .odt document with LibreOffice
* Convert and save it as an empty .doc Word 2003 document.
* Import an EMF image generated with xs2emf() in the document
* Save and close the document
* Reopen the document, still with LibreOffice: The EMF image is perfectly rendered.

Best regards
Samuel


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