# [✓] Use Show to change the style of a number line plot?

GROUPS:
 Hi everyone,I have a simple number line plot. numLinePlot = NumberLinePlot[{Interval[{0, 2}], Interval[{2, 4}], Interval[{0, 4}]}] I can use Show to change the image size and ticks, but I can't get PlotStyle to change the style of the lines. Why doesn't this work? Show[numLinePlot, PlotStyle -> {Directive[AbsoluteThickness[3], AbsolutePointSize[4], Blue], Directive[AbsoluteThickness[3], AbsolutePointSize[4], Yellow], Directive[AbsoluteThickness[3], AbsolutePointSize[4], Red]}, Ticks -> {{0, 2, 4}, Automatic}, ImageSize -> 450] Any suggestion would be much appreciated.Greg
3 months ago
5 Replies
 Vitaliy Kaurov 2 Votes Only functions that are "plots" Information["*Plot" | "*Plot3D"] can take the options that has word "plot" in them Information["Plot*"] So you should put your PlotStyle in NumberLinePlot, and only then use Show. But why if you can put everything in NumberLinePlot? I guess you got your reasons, but the truth is Show cannot take PlotStyle. numLinePlot=NumberLinePlot[ {Interval[{0,2}],Interval[{2,4}],Interval[{0,4}]}, PlotStyle->{ Directive[AbsoluteThickness[3],AbsolutePointSize[4],Blue], Directive[AbsoluteThickness[3],AbsolutePointSize[4],Yellow], Directive[AbsoluteThickness[3],AbsolutePointSize[4],Red]}, Ticks->{{0,2,4},Automatic}, ImageSize->450]
3 months ago
 Hi Vitaliy,Thanks for the clarification. The reason that I want to be able to modify plots using Show is that I create functions that return an association, and sometimes one or more of the items in the association is a plot. I thought that with Show I could then modify the plot for specific uses, for example, a research workshop, wen, a class presentation, and notes.Greg
 Here's a cute application of Iterator in the GeneralUtilities package that achieves the restyling of the plot: With[{styles = GeneralUtilitiesToIterator[ {Directive[AbsoluteThickness[3], AbsolutePointSize[4], Blue], Directive[AbsoluteThickness[3], AbsolutePointSize[4], Yellow], Directive[AbsoluteThickness[3], AbsolutePointSize[4], Red]}]}, numLinePlot /. {Longest[d__?directive], stuff___} :> {d, Read@styles, stuff} ] Of course it relies on the structure of the graphics produced by NumberLinePlot, which can be inspected.