# Diagonal position of Labels in ListPlot

I would like to plot the following data and set the labels of the point not above, not below, but at an angle -let us say 45degree- with respect to the axis. What is a straightforward approach?

data2plot={Callout[{5,45},2.1,Above,LeaderSize->24],Callout[{3.1,42},1.6,Above,LeaderSize->24],Callout[{2,41},1.1,Above,LeaderSize->24],Callout[{1,30},3.1,Above,LeaderSize->24],Callout[{2.2,47},1.9,Above,LeaderSize->24],Callout[{11.4,29.2},4.3,Above,LeaderSize->24]};

ListPlot[data2plot]

• I am not sure about specifying the angle, but you can surely specify the co-ordinates of where the label appears. For example instead of Callout[{2, 41}, 1.1, Above, LeaderSize -> 24], tryCallout[{2, 41}, 1.1, {1.5, 42}, LeaderSize -> 24] where {1,5,42} specifies the co-ordinates of the label 1.1 Jul 5, 2019 at 7:55

Change Above to Automatic and use LeaderSize -> {{length, angle, gap}, neck}:

data2plotb = data2plot /.  Callout[a_, b_, ___] :>
Callout[a, b, Automatic, LeaderSize -> {{24, 45 Degree,5}, 0}]



If your data and labels come in two lists you can use MapThread to construct a list of Callouts:

data = {{5, 45}, {3.1, 42}, {2, 41}, {1, 30}, {2.2, 47}, {11.4, 29.2}} ;
labels = {2.1, 1.6, 1.1, 3.1, 1.9, 4.3} ;
LeaderSize -> {{24, 45 Degree, 5}, 0}] &,
{data, labels}];


same picture

You might also consider using Epilog to add the labels and the connecting lines:

epilog = {MapThread[Text[#2, Offset[{15, 15}, #], {Left, Bottom}] &, {data, labels}],
Line[{ Offset[{5, 5}, #], Offset[{15, 15}, #]}] & /@ data};

ListPlot[data, Epilog -> epilog,
ImagePadding -> Scaled[.05], PlotRangeClipping -> False,
PlotRange -> {{0, 12}, All}]


• Will this translate to a Latex code? Jul 5, 2019 at 9:00
• @JoseEnriqueCalderon, I don't have any idea if/how it does.
– kglr
Jul 5, 2019 at 9:09
• @Luigi - Assuming that your original data looks like data = {{5, 45, 2.1}, {3.1, 42, 1.6}, {2, 41, 1.1}, {1, 30, 3.1}, {2.2, 47, 1.9}, {11.4, 29.2, 4.3}};  The definition of data2plot can be simplified to data2plot = Callout[Most@#, Last@#, Automatic, LeaderSize -> {{24, 45 Degree, 5}, 0}] & /@ data; ` Jul 5, 2019 at 12:40