0
$\begingroup$

I have two lists:

No.1 total

No.2 data5

I want to plot these two lists in one graph with a shared log-log scale.

option = {PlotLegends -> {"total", "data5"}, 
   LabelStyle -> Directive[Black, Bold, 20], PlotRange -> All, 
   LabelStyle -> Directive[Black, Bold], ImageSize -> {600, 400}, 
   AxesLabel -> {Style["Area[\!\(\*SuperscriptBox[\(mm\), \(2\)]\)]", 
      20], Style["Cluster number", 20]}, 
   TicksStyle -> Directive[Bold, 20], 
   PlotStyle -> ColorData[1, "ColorList"], Joined -> True, 
   PlotMarkers -> {Automatic, 15}};
p1 = ListLogLogPlot[{total}, option]
p2 = ListLogLogPlot[{total, data5}, option]

The joined line for "total" is different in p1 and p2. For p1, there are no scattered points; but for p2, some scattered points appeared. I don't know the reason. Could anyone help me explain and solve it? Thank you!

The plots for p1 and p2 can be reached here: p1 and p2.

$\endgroup$
  • $\begingroup$ The reason you get the gaps is that for ListLogLogPlot with the Joined -> True option only neighboring points with numeric values are connected. You have lots of values of Indeterminate because you have zeros in your data and the log of zero results in Indeterminate. $\endgroup$ – JimB May 24 '17 at 16:57
1
$\begingroup$

The reason you get the gaps is that for ListLogLogPlot with the Joined -> True option only neighboring points with numeric values are connected. You have lots of values of Indeterminate because you have zeros in your data and the log of zero results in Indeterminate.

But there also seems to be other funny business with ListLogLogPlot. Here is a plot of the first 4 data points from each set of data:

total = {{3.549425730917573, 0.005090023013401922},
  {3.9494257309175733, 0.0060647082712873964},
  {4.349425730917574, 0.041613645593610395},
  {4.749425730917573, 0.298578583998917}};

data5 = {{3.8393956761241834, 0.0024330900243309003},
  {4.239395676124183, 0.}, {4.639395676124184, 0.2116788321167883}, 
  {5.039395676124183, 0.45742092457420924}};

ListPlot[{total, data5}, PlotMarkers -> {Automatic, 15}, PlotRange -> All,
  ImageSize -> 500, Frame -> True, PlotLegends -> {"total", "data5"},
  PlotLabel -> "Raw data"]

Raw data

All 4 points from each dataset show up fine. Now perform a ListLogLogPlot:

ListLogLogPlot[{total, data5}, PlotMarkers -> {Automatic, 15}, PlotRange -> All,
  ImageSize -> 500, Frame -> True, PlotLegends -> {"total", "data5"},
  PlotLabel -> "ListLogLogPlot with Joined -> False"]

LogLog plot not joined

We see that the second point from data5 is missing (as one of the coordinates is zero) but also the first point from data5 is plotted twice: once with the marker from total and again with the marker from data5. I can't explain that.

When we add Joined -> True, then we get the following:

ListLogLogPlot[{total, data5}, PlotMarkers -> {Automatic, 15}, PlotRange -> All,
  ImageSize -> 500, Frame -> True, Joined -> True, PlotLegends -> {"total", "data5"},
  PlotLabel -> "ListLogLogPlot with Joined -> True"]

LogLog plot with Joined option

We see that the first point from data5 is shown with the marker from total but not with a second marker from data5 and is not connected to the third point because the second point has a zero coordinate (removed automatically because taking the log in a log-log plot results in Indeterminate.

But such weirdness goes away if the zero values are removed or changed to some positive number.

$\endgroup$

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.