0
$\begingroup$

In Mathematica v9, I was able to append / apply PlotStyle option to an existing ListPlot graph and get updated styles, such as ListPlot[undatedlinedata,PlotStyle→{Blue,Red},PlotStyle→AbsoluteThickness[5],Frame→True,Joined→True].

But in Mathematica v11, any subsequent PlotStyle option is ignored, see screenshot below for the end results of the same command in two versions.enter image description here

I understand I can use a list of Directive to update the PlotStyle, such as ListPlot[undatedlinedata,PlotStyle->{Directive[Red, AbsoluteThickness[5]], Directive[Blue, AbsoluteThickness[5]]}, Joined->True]. But things would get messy when line data is huge and there are plenty of PlotStyles already applied to the existing plot, such as default options.

Is there an easier way to append / add PlotStyle to ListPlot in Mathematica v11?

$\endgroup$
1
  • 1
    $\begingroup$ Please do not post images of your work, especially when the images display at a size that make them difficult to read. Please post your actual Mathematica code in the form of text that can be copied and pasted into a Mathematica notebook. Without such, it will be difficult to reproduce your problem and to experiment with possible solutions. $\endgroup$
    – m_goldberg
    Commented Dec 16, 2016 at 5:16

1 Answer 1

2
$\begingroup$

I think what you are seeing is a bug fix. But even under the new regime you down't have type both directives in long form. You can have a have Mathematica compute the directives for you.

SeedRandom[42];
ListPlot[{RandomReal[{0., 1.}, 6], RandomReal[{0., 1.}, 6]},
 DataRange -> {0, 5},
 PlotStyle -> 
   Evaluate[{AbsoluteThickness[5], #} & /@ {Blue, Red}],
 Frame -> True,
 Joined -> True]

plot

This kind of directive building can be extended to any number of plots and any number of option groups. You may have to switch from simple Map to MapThread.

$\endgroup$
1
  • $\begingroup$ thank you for your suggestion. I am concerned when more PlotStyles are applied down the track. In my codes, a default style is applied to ListPlot, then users can subsequently add unknown number of PlotStyles to it later. ListPlotStyles = {Frame->True, PlotStyle->{Red, Blue, Green, Black}}, ImageSize->620; SetOptions[ListPlot, ListPlotStyles]; Then later the application collects user customized input, such as Thickness, Dashing etc and apply to the plot. $\endgroup$
    – Leonx
    Commented Dec 16, 2016 at 6:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.