Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to save some graphics into a file, and it seems impossible.

x1 = Round[RandomVariate[NormalDistribution[325, 5], 25], 0.1];
x2 = Round[RandomVariate[NormalDistribution[325.5, 2], 25], 0.1];
x3 = Round[RandomVariate[NormalDistribution[327.5, 7], 25], 0.1];

h1 = Histogram[x1, 6, "Probability", 
   ChartLegends -> {"\!\(\*SubscriptBox[\(x\), \(1\)]\)"}, 
   ChartStyle -> {Directive[Red]}, 
   PlotRange -> {{308, 342}, {0, 0.5}}];
h2 = Histogram[x2, 6, "Probability", 
   ChartLegends -> {"\!\(\*SubscriptBox[\(x\), \(2\)]\)"}, 
   ChartStyle -> {Directive[Blue]}, 
   PlotRange -> {{308, 342}, {0, 0.5}}];
h3 = Histogram[x3, 6, "Probability", 
   ChartLegends -> {"\!\(\*SubscriptBox[\(x\), \(3\)]\)"}, 
   ChartStyle -> {Directive[Green]}, 
   PlotRange -> {{308, 342}, {0, 0.5}}];
   Export["C:\CompareHist.png", GraphicsColumn[{h1, h2, h3}]]

Of course I cannot use save graphics into file option as there is no such option. And by the way: why Export functions always fails? Even when trying to follow tutorial. Is it some known bug?

share|improve this question
Have you tried with "\\" rather than "\" in your file name ? – b.gatessucks Apr 2 '13 at 11:16
When no C:\ it works. But how to write paths then? – Misery Apr 2 '13 at 11:18
Have a look at FileNameJoin. – b.gatessucks Apr 2 '13 at 11:33
@b.gatessucks: Please answer this question so I can mark it as accepted answer. – Misery Apr 2 '13 at 13:03
The reason why the single backslash fails as a path separator is that the backslah acts as escape character in strings as in many programming languages. "\t", for instance, codes for the tab character. This means that if you want to have the literal backslash you need to escape that with the escape character, which is the backslash itself. So "\\" is the `\` character. – Sjoerd C. de Vries Apr 2 '13 at 19:12
up vote 5 down vote accepted

From my experience, outputting into the desktop is quite handy. Thus, in every notebook I have one initialization cell that selects the output folder


Then one that allows me to simply export every plot that I output:

Export["out.png", Out[-1]];

The problem in your exporting function is that you are not setting the directory for the figure correctly. Have a look into the exporting directory information here and, if you want to avoid doing what I suggested above, use FileNameJoin (example).

EDIT: I didn't see this, but @b.gatessucks had suggested FileNameJoin before I did.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.