4
$\begingroup$

I have the following data:

data = {25,25,20,17,5,36,4,7,11,4,16,4,4,8,10,6,6,14,7,10,5,6,4,14,9,17,5,10,8,16,4,4,4,4,16,7,17,14,25,9,5,16,10,11,7,21,19,10,8,4,11,7,10,4,16,8,6,11,8,6,4,8,19,4,9,10,8,8,5,18,5,5,11,4,10,5,6,16,10,5,5,11,13,15,5,9,7,17,5,14,4,6,4,12,6,5,4,5,5,4,5,9,9,5,7,7,10,10,4,10,5,8,6,4,6,5,11,4,11,12,5,4,5,4,8,6,16,19,5,7,5,10,4,4,7,6,11,5,19,6,5,11,5,18,9,4,4,6,5,9,12,4,8,13,12,6,5,4,13,5,10,6,7,7,5,7,25,6,4,21,9,4,5,20,4,10,5,4,7,5,18,17,12,10,6,8,19,7,6,6,18,5,8,4,12,10,5,4,6,11,13,8,4,6,5,5,5,9,10,4,4,12,9,7,9,9,6,4,19,6,8,5,12,12,6,14,9,10,17,16,7,4,5,5,13,4,5,6,8,4,6,11,6,7,5,4,4,8,10,19,5,4,10,5,5,4,5,15,9,14,17,6,7,9,4,15,9,7,18,4,9,9,4,6,11,5,7,10,4,11,9,8,14,8,10,8,8,4,5,15,5,5,5,9,9,7,13,6,8,7,5,4,6,4,6,4,4,4,8,8,5,4,4,4,4,9,7,5,7,9,5,4,4,19,6,5,9,4,8,4,4,4,8,8,6,12,16,16,17,5,5,7,6,4,16,7,5,6,15,4,8,22,20,9,13,5,6,5,5,5,12,4,12,19,5,7,9,9,6,5,6,4,8,11,8,5,4,7,8,9,8,9,6,4,6,10,8,11,7,8,9,4,5,4,5,7,7,7,6,4,4,5,12,5,7,10,9,5,10,5,4,4,5,6,4,9,5,5,6,4,6,9,5,18,12,5,10,21,16,12,7,6,9,9,10,7,7,7,12,4,5,6,13,5,6,8,7,6,10,7,9,14,4,10,6,4,5,6,9,7,4,7,9,8,5,6,6,16,6,6,8,6,4,5,6,10,20,7,5,4,10,6,8,8,12,5,10,9,18,21,5,6,5,5,14,7,14,9,5,18,9,10,17,6,4,8,4,14,7,4,4,4,4,4,4,4,8,9,10,10,7,9,4,4,12,4,4,4,11,5,8,7,4,4,21,5,7,4,7,9,4,17,6,9,6,4,4,5,4,4,13,6,5,5,4,5,5,11,11,5,8,4,5,5,18,6,8,10,11,8,7,8,8,5,5,9,5,6,4,7,4,6,5,5,9,9,5,15,7,4,7,6,8,6,9,5,5,10,9,5,11,11,5,4,11,4,6,6,5,4,5,7,5,7,14,4,4,4,4,7,8,8,7,7,5,5,12,5,8,8,10,16,5,4,5,10,12,9,7,7,4,22,4,8,12,11,5,17,7,12,10,5,7,6,10,10,4,6,6,6,4,4,9,5,6,6,5,9,10,5,6,7,5,12,4,4,4,21,8,4,6,5,5,5,6,11,12,6,13,7,4,13,8,4,9,10,5,5,8,5,5,5,9,12,6,5,8,4,10,11,13,11,16,10,5,7,7,4,4,12,5,10,5,17,9,6,6,5,6,7,7,7,9,11,8,7,8,5,5,7,5,7,11,4,8,10,6,4,4,10,10,11,5,6,8,6,8,12,9,14,10,5,13,7,10,8,7,4,6,4,20,6,8,4,11,7,5,4,5,7,5,12,9,12,7,4,5,4,5,5,10,16,11,6,5,14,10,6,4,5,4,6,6,4,7,6,5,4,5,5,10,6,6,4,4,5,9,10,5,4,9,8,4,11,8,5,9,8,5,4,8,4,11,8,9,7,8,10,4,9,13,8,5,5,7,10,5,6,16,5,4,4,7,6,4,18,11,8,4,8,9,6,9,6,10,17,14,9,5,5,9,6,10,8,4,5,10,6,6,8,9,5,8,4,6,8,10,4,6,4,5,14,8,4,9,4,4,9,8,14,4,5,6,10,6,19,4,5,4,4,9,13,7,5,7,9,5,7,7,8,5,7,5,5,9,14,10,23,6,4,4,5,4,6,14,11,8,11,10,9,5,8,7,6,13,8,8,7,6,4,12,5,8,10,5,5,4,5,8,5,4,5,9,8,7,8,5,5,9,6,6,4,5,5,5,4,5,8,7,7,11,14,6,18,6,6,5,5,6,5,12,9,6,9,7,21,7,4,7,6,9,8,7,4,5,7,10,6,9,4,5,4,9,6,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5,4,10,5,12,7,7,6,11,6,5,4,4,6,11,4,5,4,5,6,9,5,5,8,9,7,15,9,6,7,14,15,10,6,6,9,5,9,10,6,14,5,5,4,21,20,4,4,4,11,20,4,6,9,8,5,5,5,8,4,11,11,10,4,8,12,7,4,9,4,5,7,9,4,6,4,4,4,5,4,11,6,6,4,4,5,7,10,5,5,10,5,4,5,4,12,5,19,5,9,11,10,13,11,7,7,14,5,12,7,7,7,9,13,10,5,4,8,4,9,5,10,5,7,6,6,5,9,10,4,12,9,7,4,4,8,6,9,7,10,6,5,11,11,7,15,8,5,6,8,6,11,10,4,5,5,4,7,11,5,4,4,6,9,12,11,16,15,8,6,5,10,10,6,4,5,4,13,5,13,21,5,5,5,6,5,4,12,5,4,5,8,11,11,5,4,11,4,9,18,16,5,4,5,8,4,12,9,4,5,4,6,5,4,5,11,6,6,9,12,12,10,7,4,4,5,5,19,5,10,6,6,4,5,6,5,12,6,4,5,13,13,7,8,4,4,6,13,7,6,8,14,22,8,6,6,5,10,15,5,5,14,7,7,6,5,6,7,10,6,4,7,10,6,13,5,11,6,7,4,5,11,6,5,6,4,5,5,6,5,20,14,7,11,4,6,9,4,12,7,6,7,6,4,5,7,5,7,11,6,5,4,10,4,11,18,15,4,4,5,7,6,8,8,5,11,10,19,12,9,4,4,4,5,6,4,5,5,5,4,6,5,7,4,5,6,5,4,4,11,7,4,4,5,4,5,10,6,4,6,10,6,9,4,11,6,5,13,8,10,9,8,6,8,4,5,19,5,8,15,9,8,5,10,6,18,5,8,15,8,8,19,7,4,6,4,11,9,16,22,4,12,22,5,7,12,7,12,18,10,17,8,6,15,23,7,4,8,8,11,6,8,6,7,5,10,6,5,12,6,10,23,7,4,6,10,20,4,6,12,8,4,11,17,9,11,6,4,6,4,17,10,9,9,8,10,6,5,17,6,4,9,7,22,10,16,4,4,10,9,10,8,6,11,4,5,10,6,15,17,18,21,6,6,22,19,24,14,6,5};

Now I produce a logarithmic histogramm:

plot = Histogram[data, {1}, Frame -> True, 
  ScalingFunctions -> "Log", 
  FrameLabel -> {{"count", ""}, {"data", "title"}}, 
  PlotRangePadding -> {{0, Automatic}, {0, Automatic}}]

enter image description here

(I want to use Frame->True)

How can I force that the right bars are not out of the frame? The should exactly be at the right edge?

Second real problem:

I want to export this plot as a PDF file:

Export[StringJoin[$HomeDirectory, "\\plot.pdf"], plot, "PDF"];

The result is: the PDF plot has no axes numbering and no labels and also the bars at the right edge look different.

enter image description here

$\endgroup$
4
$\begingroup$

Using PlotRange -> All fixes the first issue:

plot = Histogram[data, {1}, Frame -> True, ScalingFunctions -> "Log", 
  FrameLabel -> {{"count", ""}, {"data", "title"}}, PlotRange -> All]

enter image description here

Exporting the Rasterized version of plot fixes the second issue:

Import[Export["plot.pdf", Rasterize[plot, RasterSize -> 600], "PDF"]]

enter image description here

$\endgroup$
  • $\begingroup$ Great solution. How can you adjust (for the first question), that the most right bar ends exactly at the right edge of the plot? Scaled[.3] should then be substituted by something different. $\endgroup$ – mrz Feb 12 at 11:03
  • 1
    $\begingroup$ @mrz, please see the new version, $\endgroup$ – kglr Feb 12 at 11:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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