Message Boards Message Boards

2
|
6422 Views
|
4 Replies
|
7 Total Likes
View groups...
Share
Share this post:

ColorFunction misbehaving for a simple Plot

Posted 12 years ago
I'm working through the new data structures in Mathematica 9 and didn't like the way the missing regions of a TemporalData plot were overlaid in the Documentation,
missingData={2,1,3,Missing[],2,1,2,Missing[],6,2,5};
thirdTemporalData=TemporalData[missingData, Automatic, MissingDataMethod -> Automatic,
Method->{"Interpolation",InterpolationOrder->3},MetaInformation->{"MissingTimes"->dummy}];
dummy=Flatten[Position[missingData,_Missing]-1];
Show[Plot[thirdTemporalData["PathFunction"][x], {x, 0, 10}],
Table[Plot[thirdTemporalData["PathFunction"][x], {x, i, i + 1},
PlotStyle -> {Thick, Red}],{i, thirdTemporalData["MissingTimes"]}]]
I didn't like it because when I provided this to Manipulate and switch to the "highlighted" and none "highlighted" plot it changes the graphic size and PlotRange. Also it isn't as flexible as Id' like. So I tried the following, but it makes the plot look like I've drawn it with a pencil (http://imgur.com/gMRRfQ3 in case that image isn't embedded):
Plot[thirdTemporalData["PathFunction"][t], {t, 0, 10},
PlotRange -> All,ColorFunction->Function[{x, y}, If[3 <= x <= 4 || 7 <= x <= 8, Red,PlotStyle->Automatic]],ColorFunctionScaling->False]


Can anyone explain this and give fix? Thanks.
POSTED BY: Martin Hadley
4 Replies
Here is the screenshot of highest quality setting mentioned by Brett: 
Top menu > Edit > Preferences > Appearance > Graphics > Antialiasing Quality

POSTED BY: Vitaliy Kaurov
The plot using ColorFunction has VertexColors in it, and so uses the 3D renderer. As a result, it's not
getting antialiased, either because the graphic card doesn't support it, or it's not turned on in Mathematica
(Preferences > Appearance > Graphics > Antialiasing Quality.)
POSTED BY: Brett Champion
Thanks for your reply Giullio. Your implementation of switching between the two plots is much neater than my own - I hadn't thought to use Join like that!
POSTED BY: Martin Hadley
While the second one is definitely a issue with the ColorFunction rendering (and you may consider contacting Wolfram support) I am not able to reproduce what you mention in the second paragraph. Neither the graphic size nor the range are changed in this formulation:
 Manipulate[Show[
   Join[{
     Plot[thirdTemporalData["PathFunction"][x], {x, 0,
       Length[missingData] - 1}]},
    If[highlight, {Table[
       Plot[thirdTemporalData["PathFunction"][x], {x, i - 1, i + 1},
        PlotStyle -> {Thick, Red}], {i,
        thirdTemporalData["MissingTimes"]}]}, {}]]],
 
{highlight, {False, True}}]
Note, I have modified the range of the second plot to better represent the interpolated segments. Could you please post your own code for this so that we can see what caused you problems?

P.S.: this is a shorter code that pinpoints the issue
Plot[Sin[3 t], {t, 0, 2 Pi}, PlotStyle -> Thickness[.01],
ColorFunction -> (If[# < Pi, Red] &), ColorFunctionScaling -> False]
Plot[Sin[3 t], {t, 0, 2 Pi}, PlotStyle -> Thickness[.01]]
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