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}]
ListPlot[data2plotb, ImagePadding -> Scaled[.05]]
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} ;
data4plotting = MapThread[Callout[##, Automatic,
LeaderSize -> {{24, 45 Degree, 5}, 0}] &,
{data, labels}];
ListPlot[data4plotting, ImagePadding -> Scaled[.05]]
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}]
Note: LeaderSize >> Details
:
, 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 $\endgroup$