Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12264 > unrolled thread
| Started by | Szymon Roziewski <szymon.roziewski@gmail.com> |
|---|---|
| First post | 2012-11-07 05:57 +0000 |
| Last post | 2012-11-13 05:15 +0000 |
| Articles | 6 — 5 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Export a graphical plot to pdf file Szymon Roziewski <szymon.roziewski@gmail.com> - 2012-11-07 05:57 +0000
Re: Export a graphical plot to pdf file "Nasser M. Abbasi" <nma@12000.org> - 2012-11-09 00:03 +0000
Re: Export a graphical plot to pdf file "Kevin J. McCann" <kjm@KevinMcCann.com> - 2012-11-10 07:09 +0000
Re: Export a graphical plot to pdf file RBaillie <bobbaillie@frii.com> - 2012-11-10 07:09 +0000
Re: Export a graphical plot to pdf file Kristjan Kannike <kkannike@ut.ee> - 2012-11-10 08:30 +0000
Re: Export a graphical plot to pdf file Szymon Roziewski <szymon.roziewski@gmail.com> - 2012-11-13 05:15 +0000
| From | Szymon Roziewski <szymon.roziewski@gmail.com> |
|---|---|
| Date | 2012-11-07 05:57 +0000 |
| Subject | Export a graphical plot to pdf file |
| Message-ID | <k7ct90$dqe$1@smc.vnet.net> |
Hi there,
I have a ContourPlot result which I need to put into pdf file.
The problem is that the filled area is in a mess, I mean there are lots of
thin white stripes on it.
For example, please try out this bunch of code
gr = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}];
Export["file.pdf", gr]
Best regards,
Szymon Roziewski
[toc] | [next] | [standalone]
| From | "Nasser M. Abbasi" <nma@12000.org> |
|---|---|
| Date | 2012-11-09 00:03 +0000 |
| Message-ID | <k7hh8e$o1m$1@smc.vnet.net> |
| In reply to | #12264 |
On 11/6/2012 11:57 PM, Szymon Roziewski wrote:
> Hi there,
>
> I have a ContourPlot result which I need to put into pdf file.
> The problem is that the filled area is in a mess, I mean there are lots of
> thin white stripes on it.
>
> For example, please try out this bunch of code
>
> gr = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}];
> Export["file.pdf", gr]
>
>
> Best regards,
> Szymon Roziewski
>
Do not know much about this, but trying few things, I found this
to produce good image in the PDF file (no white stripes on it)
---------------------------
gr = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}]
Export["file.pdf", Rasterize[gr, ImageResolution -> 128]]
--------------------------------
You can change the options to Rasterize to see which gives
you best image in the PDF.
To obtain more information on the pdf file generated by
the export, you can list the Elements. something like:
---------------------------
lis = Import["file.pdf", "Elements"]
Grid[
Table[{lis[[i]], Import["file.pdf", lis[[i]]]}, {i, 1, Length[lis]}],
Frame -> All]
------------------------------
Another thing to try is to issue the command
SetOptions[$FrontEndSession, PrintingStyleEnvironment -> "Working"]
first before exporting. Again, this is something to try.
But the Rasterize'd image in PDF do not have the white stripes
any more.
--Nasser
[toc] | [prev] | [next] | [standalone]
| From | "Kevin J. McCann" <kjm@KevinMcCann.com> |
|---|---|
| Date | 2012-11-10 07:09 +0000 |
| Message-ID | <k7kujl$2aa$1@smc.vnet.net> |
| In reply to | #12295 |
I have not done this; however, I frequently print out entire notebooks
as PDF's, and they appear fine. You could do that and then cut and paste
the PDF version of the plot. Just a suggestion.
Kevin
On 11/8/2012 7:03 PM, Nasser M. Abbasi wrote:
> On 11/6/2012 11:57 PM, Szymon Roziewski wrote:
>> Hi there,
>>
>> I have a ContourPlot result which I need to put into pdf file.
>> The problem is that the filled area is in a mess, I mean there are lots of
>> thin white stripes on it.
>>
>> For example, please try out this bunch of code
>>
>> gr = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}];
>> Export["file.pdf", gr]
>>
>>
>> Best regards,
>> Szymon Roziewski
>>
>
> Do not know much about this, but trying few things, I found this
> to produce good image in the PDF file (no white stripes on it)
>
> ---------------------------
> gr = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}]
> Export["file.pdf", Rasterize[gr, ImageResolution -> 128]]
> --------------------------------
>
> You can change the options to Rasterize to see which gives
> you best image in the PDF.
>
> To obtain more information on the pdf file generated by
> the export, you can list the Elements. something like:
>
> ---------------------------
> lis = Import["file.pdf", "Elements"]
> Grid[
> Table[{lis[[i]], Import["file.pdf", lis[[i]]]}, {i, 1, Length[lis]}],
> Frame -> All]
> ------------------------------
>
> Another thing to try is to issue the command
>
> SetOptions[$FrontEndSession, PrintingStyleEnvironment -> "Working"]
>
> first before exporting. Again, this is something to try.
> But the Rasterize'd image in PDF do not have the white stripes
> any more.
>
> --Nasser
>
>
>
>
>
[toc] | [prev] | [next] | [standalone]
| From | RBaillie <bobbaillie@frii.com> |
|---|---|
| Date | 2012-11-10 07:09 +0000 |
| Message-ID | <k7kujv$2ad$1@smc.vnet.net> |
| In reply to | #12264 |
Unfortunately, exporting to pdf has not worked properly since version
5.2. This export works fine in 5.2.
gr = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}];
Export["file.pdf", gr]
Moreover, the file created with version 5.2 is far smaller than with
later versions.
Often, using the
"AllowRasterization" -> False
option greatly improves exports to pdf with version 8, but it does not
work in this case.
[toc] | [prev] | [next] | [standalone]
| From | Kristjan Kannike <kkannike@ut.ee> |
|---|---|
| Date | 2012-11-10 08:30 +0000 |
| Message-ID | <k7l3bn$2mp$1@smc.vnet.net> |
| In reply to | #12264 |
Hello, The problem is that ContourPlot, DensityPlot etc. compose their plot of lots of tiny polygons. PDF is a vector format and preserves them all. The PDF file becomes large and loads and scrolls slowly. There is a FixPolygons package that merges polygons of the same colour that results in drastically reduced PDF size: https://github.com/wspr/mmapkg This works well with ContourPlot. Unfortunately not so well (sometimes) with DensityPlot as its polygons are filled with gradients, not one colour. Best, Kristjan Kannike On Thu, 8 Nov 2012, Nasser M. Abbasi wrote: > On 11/6/2012 11:57 PM, Szymon Roziewski wrote: > > Hi there, > > > > I have a ContourPlot result which I need to put into pdf file. > > The problem is that the filled area is in a mess, I mean there are lots of > > thin white stripes on it.
[toc] | [prev] | [next] | [standalone]
| From | Szymon Roziewski <szymon.roziewski@gmail.com> |
|---|---|
| Date | 2012-11-13 05:15 +0000 |
| Message-ID | <k7sl0k$kut$1@smc.vnet.net> |
| In reply to | #12264 |
Thank you all for your help.
This solution works almost well
antialias[g_] :=
ImageResize[
Rasterize[g, "Image", ImageResolution -> 600, Background -> White],
Scaled[2]]
g = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}];
img = antialias[Show[g, Axes -> False, Boxed -> False]];
Export["file.pdf", img, "AllowRasterization" -> False]
I mean the problem is with its background that is light red but it should
be white.
Best wishes,
Szymon Roziewski
On 12 November 2012 12:06, Szymon Roziewski <szymon.roziewski@gmail.com>wrote:
> Thank you all for your help.
>
> This solution works almost well
>
> antialias[g_] :=
> ImageResize[
> Rasterize[g, "Image", ImageResolution -> 600, Background -> White],
> Scaled[2]]
>
> g = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}];
> img = antialias[Show[g, Axes -> False, Boxed -> False]];
> Export["file.pdf", img, "AllowRasterization" -> False]
>
> I mean the problem is with its background that is light red but it should
> be white.
>
> Best wishes,
> Szymon Roziewski
>
--
Z wyrazami szacunku,
Szymon Roziewski
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web