Message Boards Message Boards

0
|
11627 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:

ListPlot and empty lists?

Posted 10 years ago
POSTED BY: David Keith
7 Replies
Posted 5 years ago

I am having this exact issue as well, in 11.3, but with ListPointPlot3D. I found the replacement rules with Missing[] or \[EmptySet] got rid of the errors, but didn't actually make the plot. I ended up instead replacing the empty lists with a single point at the origin, and then adding an If statement to PlotStyle to assign None if the length was zero., which preserved the structure of the Legend

POSTED BY: Evan Johnson
Posted 10 years ago
POSTED BY: David Keith

When I have had to deal with this issue I have generally replaced the empty list by a list with a single element with the value Missing[]. In the case of DateListPlot, I use an arbitrary date with its corresponding value as Missing[]. E.g.

ListPlot[{d, {Missing[]}}]
POSTED BY: David Reiss

Hi David,

I guess, that the same trick works:

DateListPlot[{FinancialData["GE", "Jan. 1, 2000"], FinancialData["AA", "Jan. 1, 2000"], {{{},}}},  PlotLegends -> Automatic]

The full version would be something like:

DateListPlot[{FinancialData["GE", "Jan. 1, 2000"], FinancialData["AA", "Jan. 1, 2000"], {}} /. {} -> {{{},}}, PlotLegends -> Automatic]

which gives

enter image description here

The main idea is that DateListPlot requires data in a different format from ListPlot. Roughly speaking a valid "empty set" for ListPlot, if the other lists are of the form {x,y}, is

{\[EmptySet]}

whereas DateListPlot requires a different "empty set". I suppose that there is a much nicer argument/way of solving this though.

Cheers,

Marco

POSTED BY: Marco Thiel
Posted 10 years ago

I thought I would try the same solution with DateListPlot, but it doesn't like the empty set.

POSTED BY: David Keith
Posted 10 years ago

Thank you, Marco. That is extremely useful By not stripping lists, I meant I would not what to just delete a list from the list of lists based on it having Length 0. But I can certainly run this rule and that will be much cleaner than handling the 4 cases separately. You rock!

POSTED BY: David Keith
POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract