4
$\begingroup$

I'm currently working on a bar chart diagram, where the vertical axis starts from 0.9. I managed to adjust the labels, but I don't know how to rotate it to make it readable.

The code is the following:

selectName = {"Downhill Simplex", "Downhill Simplex step 1 weight 10",
    "Downhill Simplex step 2 weight 10", 
   "Downhill Simplex step 3 weight 10", "Hooke Jeves", 
   "Hooke Jeeves step 1 weight 10", "Hooke Jeeves step 2 weight 10", 
   "Hooke Jeeves step 1 weight 10", "ASA"};
selectR2 = {0.999188735078198`, 0.999532701011065`, 
   0.998304716112723`, 0.992933005217847`, 0.999151413601683`, 
   0.999383404177847`, 0.99912182243453`, 0.996900703923443`, 
   0.99927713576775`};
ch = BarChart[selectR2, BarSpacing -> Large, 
   PlotRange -> {Automatic, {0.9, 1}}, 
   PlotRangePadding -> {Automatic, 0}, PlotRangeClipping -> True, 
   ChartLabels -> selectName];
labels = Cases[ch[[1]], 
  Text[lbl_, Offset[_, {pos_, _}], ___] :> {pos, lbl, 0}, -4]
Show[ch, Ticks -> {labels, Automatic}, Axes -> True]

enter image description here

Thanks for your help in advance.

$\endgroup$

1 Answer 1

2
$\begingroup$

(1) Subtract .9 from input data and adjust the tick labels for the vertical axis to run from .9 to 1, and (2) Use the third argument of Placed to rotate the chart labels in ChartLabels settings:

BarChart[selectR2 - .9, BarSpacing -> Large, 
  ChartLabels -> Placed[selectName, Below, Rotate[#, 80 Degree] &], 
  Ticks -> {None, Charting`FindTicks[{0, .1}, {.9, 1}]}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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