Re: i get an empty figure when exporting it, if I keep
- To: mathgroup at smc.vnet.net
- Subject: [mg112122] Re: i get an empty figure when exporting it, if I keep
- From: Themis Matsoukas <tmatsoukas at me.com>
- Date: Tue, 31 Aug 2010 04:17:55 -0400 (EDT)
Andy & Mirela, I can confirm that the graphic file is empty in the code given by Mirela (you have to plot something that spans the negative axes -- see example below). This is the case whether you Export into a file (pdf or eps), copy/paste to another application, or copy to clipboard and transfer to preview.app with command-N. But if you print the whole notebook into a pdf, the graphic is included. The problem seems to be a conflict between Epilog and ScientificTicks. If you remove either one, the graphic is saved correctly. In the example below I removed the ScientificTicks wrapper and everything works as expected. I would treat this as a bug in Mathematica because the graphic shows correctly on screen and there is nothing to alert the user that when saving to a file the graphic disappears. By the way, there ought to be a simpler way to print labels in scientific format --although a quick search in the help files did not come up with anything. Themis $Version "7.0 for Mac OS X x86 (64-bit) (November 11, 2008)" result = resultmodif = Table[{i, i}, {i, -80000, 80000, 2000}]; SetDirectory@NotebookDirectory[]; (* Using ScientificTicks*) ScientificTicks[plot_Graphics, xSci_: False, ySci_: True] := Module[{t}, Show[plot, Ticks -> {(t = Ticks /. AbsoluteOptions[plot, Ticks])[[1]] /. If[xSci, {x_, xlab_?NumericQ, r__} -> {x, ScientificForm[x, NumberFormat -> (Row[{#1, "e", #3}] &)], r}, {}], t[[2]] /. If[ySci, {y_, ylab_?NumericQ, r__} -> {y, ScientificForm[y, NumberFormat -> (Row[{#1, "e", #3}] &)], r}, {}]}]]; MyGraphSciTicks = ScientificTicks[ ListPlot[{result, resultmodif}, PlotRange -> Full, AxesOrigin -> {0, 0}, Joined -> True, PlotStyle -> {Black, Red}, AspectRatio -> 2, Epilog -> {Inset[ Labeled[Framed[ ScientificTicks[ ListPlot[{result, resultmodif}, PlotRange -> {{4.54, 4.6}, {-4480, -4250}}, Joined -> True, PlotStyle -> {Black, Red}, ImageSize -> 110, Ticks -> {{4.56, 4.58}, {-4400, -4300}}], False, True]], "Zoom In", Top], {8, -35000}], Text[Style["h[\[Mu]m]", 14], {10, -6000}], Text[Style[ "Im[\!\(\*SuperscriptBox[\"\[Omega]\", \"*\"]\)][\!\(\*SuperscriptBox[\ \"s\", RowBox[{\"-\", \"1\"}]]\)]", 14], {2.5, -70000}]}], False, True] Export["MyGraphSciTicks.pdf", MyGraphSciTicks, "PDF"] (*Without ScientificTicks*) MyGraph = ListPlot[{result, resultmodif}, PlotRange -> Full, AxesOrigin -> {0, 0}, Joined -> True, PlotStyle -> {Black, Red}, AspectRatio -> 2, Epilog -> {Inset[ Labeled[Framed[ ListPlot[{result, resultmodif}, PlotRange -> {{4.54, 4.6}, {-4480, -4250}}, Joined -> True, PlotStyle -> {Black, Red}, ImageSize -> 110, Ticks -> {{4.56, 4.58}, {-4400, -4300}}]], "Zoom In", Top], {8, -35000}], Text[Style["h[\[Mu]m]", 14], {10, -6000}], Text[Style[ "Im[\!\(\*SuperscriptBox[\"\[Omega]\", \ \"*\"]\)][\!\(\*SuperscriptBox[\"s\", RowBox[{\"-\", \"1\"}]]\)]", 14], {2.5, -70000}]}] Export["MyGraph.pdf", MyGraph, "PDF"]