Saving (Programatically)
You can programmatically save the figure in a number of formats with the save
function:
1 |
|
or
1 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
More examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1 2 3 4 5 6 7 8 9 10 11 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
|
The first option (save(filename)
) infers the appropriate file format from the filename extension. In both cases (save(filename)
and save(filename,fileformat)
), this function temporarily changes the backend to a non-interactive backend appropriate to draw the figure. A different backend is used for each format and, depending on the format, the final image does not necessarily match what is on the interactive plot window. The reason is that some file formats purposefully do not include the same features.
For instance, consider the bar chart generated by
1 2 |
|
If we export the image with
1 |
|
we get the vector graphics
See result
Exporting the image with
1 |
|
generates a representation of the image appropriate for text or markdown files, such as
See result
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
As the last example, saving an image with
1 |
|
would save the image in a format appropriate to embed in latex documents, such as
See result
This exports the image in a format in which the labels are replaced by latex text so that the plot fits the rest of the document.