2
$\begingroup$

I have two lists that I want to plot with ListLinePlot:

list1 = {1, Missing, 3, Missing, 1, 1, 1, Missing, 2, 2, Missing, 1, 2, 1, 1, 2, Missing, 3, Missing, 2, 3, 3, 4, Missing, Missing, 2, Missing, Missing, 1, 3, Missing, 1, 4, 2, 3, 10, 3, 8, 4, 10, 4, 6, 5, 3};
list2 = Range[44];
ListLinePlot[{list1, list2}]

However the plot that I produce with this code is wrong enter image description here

When I replace all Missing Values with 0 like this:

ListLinePlot[list1/. Missing -> 0, list2}]

I will get a correct plot like this: enter image description here

I just want list1 with missing values to be displayed a the correct position... But as you can see, the first and third value of list1is not displayed in the plot. Why? Many thanks in advance

$\endgroup$
2
  • 1
    $\begingroup$ You say that you get the "correct plot" by just replacing Missing with 0. What is wrong with that? "I just want list1 with missing values to be displayed a the correct position." I don't know what you mean by this. Can you explain more clearly what you're trying to do here? $\endgroup$ Commented Jul 9 at 18:07
  • $\begingroup$ @march: I would also like to show the data gaps (i.e. missing values). But did not think about that there could be a problem if a data point is "isolated" by Missing values which is of course a problem when plotting a Lineplot... $\endgroup$ Commented Jul 9 at 18:47

1 Answer 1

5
$\begingroup$

Points that do not have any neighbors except Missing cannot be connected to anything, i.e. no line connects them. But if you add PlotMarkers -> Automatic you will see also these isolated points.

list1 = {1, Missing, 3, Missing, 1, 1, 1, Missing, 2, 2, Missing, 1, 
   2, 1, 1, 2, Missing, 3, Missing, 2, 3, 3, 4, Missing, Missing, 2, 
   Missing, Missing, 1, 3, Missing, 1, 4, 2, 3, 10, 3, 8, 4, 10, 4, 6,
    5, 3};
list2 = Range[44];
ListLinePlot[{list1}, PlotMarkers -> Automatic]

enter image description here

$\endgroup$
1
  • $\begingroup$ Many thanks, could have tried that before I asked... $\endgroup$ Commented Jul 9 at 18:44

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.