2
$\begingroup$

I have created a bar chart, but I have some issues with the labeling of the sample in X-axis. May I seek help to find out how can I rotate the label in the X-axis direction. Appreciate the help. Thank you.

JoinData =  Join[{Data5s1A, Data5s2A, Data5s3A, Data5s1B, Data5s2B, Data5s3B,Data7s1A, Data7s2A, Data7s1B, Data7s2B, Data10Ys1A, Data10Ys2A,Data10Ys3A, Data10Ys1B, Data10Ys2B, Data10Ys3B, Data10Xs1A,Data10Ys3A, Data10Ys1B, Data10Ys2B, Data10Ys3B, Data10Xs1A, Data10Xs2A, Data10Xs3A, Data10Xs1B, Data10Xs2B, Data10Xs3B,Data20Ys1A, Data20Ys2A, Data20Ys1B, Data20Ys2B, Data20Xs1A, Data20Xs2A, Data20Xs1B, Data20Xs2B, Data27s1A, Data27s2A,Data27s3A, Data27s1B, Data27s2B, Data27s3B, Data30s1A, Data30s2A,Data30s3A, Data30s1B, Data30s2B, Data30s3B}]

{0.00966667, 0.00216667, -0.001, 0.0215, 0.0116667, 0.0228333, 0.005, -0.00333333, 0.015, 0.01, 0.015, 0.025, 0.0266667, 1/30, 0.0266667, 0.0266667, 0.0233333, 0.00166667, 0.00333333, 0.03, 0.0183333, 0.0116667, 0.08, 0.0833333, 0.0266667, 0.0516667, 0.0516667, 0.0333333, 0.005, 0.0116667, 0.055, 0.04, 0.0116667, 0.0383333, 0.08, 0.0233333, 0.045, 0.103333, 0.11, 0.04, 0.16, 0.0716667}

label = {"5 S1A", "5 S2A", "5 S3A", "5 S1B", "5 S2B", "5 S3B","7 S1A", "7 S2A", "7 S1B", "7 S2B", "10YS1A", "10YS2A", "10YS3A","10YS1B", "10YS2B", "10Y3B", "10XS1A", "10XS2A", "10XS3A","10XS1B", "10XS2B", "10X3B", "20YS1A", "20YS2A", "20YS1B","20YS2B", "20XS1A", "20XS2A", "20XS1B", "20XS2B", "27 S1A","27 S2A", "27 S3A", "27 S1B", "27 S2B", "27 S3B", "30 S1A","30 S2A", "30 S3A", "30 S1B", "30 S2B", "30 S3B"};

BarChart[{JoinData}, PlotLabel -> "Overall", 
 AxesLabel -> {"", "\[CapitalDelta]k\[CapitalOmega]/n"}, 
 ChartLabels -> Placed[label, Axis], Frame -> All, 
 PlotRange -> {-0.05, 0.2}]
$\endgroup$
  • 2
    $\begingroup$ junliang04, just noticed that you have not accepted any answers to you questions and your profile says "This user has not cast any votes" although you have been a member for more than a year. Please consider voting for answers and questions that you find useful. $\endgroup$ – kglr Jul 5 '18 at 6:55
  • $\begingroup$ Hi Kglr, May i ask how can i cast the vote? $\endgroup$ – ljsg Jul 5 '18 at 7:13
  • $\begingroup$ Hi ljsg, Our standard welcome message: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – kglr Jul 5 '18 at 7:18
5
$\begingroup$

Using the third argument of Placed to rotate the labels,

ChartLabels -> Placed[label, Axis, Rotate[#, 90 Degree] &]

we get

enter image description here

You get the same result by wrapping each label with Rotate[#, 90 Degree], that is, using

ChartLabels -> Placed[Rotate[#, 90 Degree] & /@ label, Axis]

gives the same output as above.

$\endgroup$
  • $\begingroup$ Is there no way to achieve the same results without separately setting the label variable, similarly to ChartLabels -> Automatic ? $\endgroup$ – alancalvitti Sep 29 '18 at 20:41
  • $\begingroup$ @alancalvitti, not sure i understand; you mean to get the labels (in some way) from the input data? $\endgroup$ – kglr Sep 29 '18 at 22:04
  • $\begingroup$ Right, why should users have to specify the list of labels when Automatic can reference them? Why can't the options be: ChartLabels->Automatic, Rotate-> 90 Degree? $\endgroup$ – alancalvitti Sep 30 '18 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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