# PlotStyle don't follows the color range

Posted 6 months ago
807 Views
|
7 Replies
|
4 Total Likes
|
 Dear All,PlotStyle doesn't work as it should. The PlotStyle does not follow the "colorRange". There are three different colors (green, blue and red), but they all stay in green?Please can you help !Thanks in advance,.... Jos data = { {{2020, 7, 29, 22, 30}, 0}, {{2020, 7, 29, 22, 45}, 2}, {{2020, 7, 29, 22, 58}, 3}, {{2020, 7, 29, 23, 0}, 2}, {{2020, 7, 29, 23, 8}, 2}, {{2020, 7, 29, 23, 39}, 3}, {{2020, 7, 29, 23, 40}, 3}, {{2020, 7, 30, 2, 38}, 2}, {{2020, 7, 30, 2, 42}, 2}, {{2020, 7, 30, 2, 47}, 2}, {{2020, 7, 30, 2, 48}, 2}, {{2020, 7, 30, 2, 49}, 2}, {{2020, 7, 30, 5, 5}, 4}, {{2020, 7, 30, 5, 6}, 4}, {{2020, 7, 30, 5, 7}, 3}, {{2020, 7, 30, 5, 51}, 2}, {{2020, 7, 30, 5, 52}, 3}, {{2020, 7, 30, 5, 53}, 2}, {{2020, 7, 30, 5, 54}, 3}, {{2020, 7, 30, 5, 55}, 3}, {{2020, 7, 30, 6, 32}, 2}, {{2020, 7, 30, 6, 33}, 3}, {{2020, 7, 30, 6, 34}, 3}, {{2020, 7, 30, 6, 35}, 0}}; colorRange = { Green, Blue, Red, Blue, Blue, Blue, Blue, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Green}; DateListPlot[data , AspectRatio -> 0.8/3, Filling -> Axis, FrameTicks -> {Automatic, {{{{2020, 7, 29, 22, 30}, "\!$$\* StyleBox[\"22\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\"30\",\nFontColor->RGBColor[1, 0, 0]]$$"}, {{2020, 7, 29, 23, 00}, "23:00"}, {{2020, 7, 29, 24, 00}, "24:00"}, {{2020, 7, 30, 01, 00}, "01:00"}, {{2020, 7, 30, 02, 00}, "02:00"}, {{2020, 7, 30, 03, 00}, "03:00"}, {{2020, 7, 30, 04, 00}, "04:00"}, {{2020, 7, 30, 05, 00}, "05:00"}, {{2020, 7, 30, 06, 00}, "06:00"}, {{2020, 7, 30, 06, 35}, "\!$$\* StyleBox[\"06\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\"35\",\nFontColor->RGBColor[1, 0, 0]]$$"}}, None}}, ImageSize -> 600, Joined -> False, LabelStyle -> Directive[Black, Bold, 10] , PlotStyle -> colorRange ] 
7 Replies
Sort By:
Posted 6 months ago
 Look what happens here DateListPlot[List /@ data, PlotStyle -> colorRange] 
Posted 6 months ago
 Sort of a workaround: data = {{{2020, 7, 29, 22, 30}, 0}, {{2020, 7, 29, 22, 45}, 2}, {{2020, 7, 29, 22, 58}, 3}, {{2020, 7, 29, 23, 0}, 2}, {{2020, 7, 29, 23, 8}, 2}, {{2020, 7, 29, 23, 39}, 3}, {{2020, 7, 29, 23, 40}, 3}, {{2020, 7, 30, 2, 38}, 2}, {{2020, 7, 30, 2, 42}, 2}, {{2020, 7, 30, 2, 47}, 2}, {{2020, 7, 30, 2, 48}, 2}, {{2020, 7, 30, 2, 49}, 2}, {{2020, 7, 30, 5, 5}, 4}, {{2020, 7, 30, 5, 6}, 4}, {{2020, 7, 30, 5, 7}, 3}, {{2020, 7, 30, 5, 51}, 2}, {{2020, 7, 30, 5, 52}, 3}, {{2020, 7, 30, 5, 53}, 2}, {{2020, 7, 30, 5, 54}, 3}, {{2020, 7, 30, 5, 55}, 3}, {{2020, 7, 30, 6, 32}, 2}, {{2020, 7, 30, 6, 33}, 3}, {{2020, 7, 30, 6, 34}, 3}, {{2020, 7, 30, 6, 35}, 0}}; colorRange = {Green, Blue, Red, Blue, Blue, Blue, Blue, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Green}; pos = Map[Flatten, Position[colorRange, #] & /@ {Green, Blue, Red}, {1}]; ptgrn = data[[#]] & /@ pos[[1]]; ptblu = data[[#]] & /@ pos[[2]]; ptred = data[[#]] & /@ pos[[3]]; DateListPlot[{ptgrn, ptblu, ptred}, AspectRatio -> 0.8/3, Filling -> Axis, FrameTicks -> {Automatic, {{{{2020, 7, 29, 22, 30}, "\!$$\* StyleBox[\"22\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\"30\",\nFontColor->RGBColor[1, 0, 0]]$$"}, {{2020, 7, 29, 23, 00}, "23:00"}, {{2020, 7, 29, 24, 00}, "24:00"}, {{2020, 7, 30, 01, 00}, "01:00"}, {{2020, 7, 30, 02, 00}, "02:00"}, {{2020, 7, 30, 03, 00}, "03:00"}, {{2020, 7, 30, 04, 00}, "04:00"}, {{2020, 7, 30, 05, 00}, "05:00"}, {{2020, 7, 30, 06, 00}, "06:00"}, {{2020, 7, 30, 06, 35}, "\!$$\* StyleBox[\"06\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\"35\",\nFontColor->RGBColor[1, 0, 0]]$$"}}, None}}, ImageSize -> 600, Joined -> False, LabelStyle -> Directive[Black, Bold, 10], PlotStyle -> {{PointSize[.02], Green}, {PointSize[.015], Blue}, {PointSize[.0095], Red}}] 
Posted 6 months ago
 Your variable data contains only one dataset, so WL reads only the first directive in Plotstyle. For the color specifications that you need it is enough to wrap you variable data as follows  DateListPlot[ Partition[data, 1], ...]  data = { {{2020, 7, 29, 22, 30}, 0}, {{2020, 7, 29, 22, 45}, 2}, {{2020, 7, 29, 22, 58}, 3}, {{2020, 7, 29, 23, 0}, 2}, {{2020, 7, 29, 23, 8}, 2}, {{2020, 7, 29, 23, 39}, 3}, {{2020, 7, 29, 23, 40}, 3}, {{2020, 7, 30, 2, 38}, 2}, {{2020, 7, 30, 2, 42}, 2}, {{2020, 7, 30, 2, 47}, 2}, {{2020, 7, 30, 2, 48}, 2}, {{2020, 7, 30, 2, 49}, 2}, {{2020, 7, 30, 5, 5}, 4}, {{2020, 7, 30, 5, 6}, 4}, {{2020, 7, 30, 5, 7}, 3}, {{2020, 7, 30, 5, 51}, 2}, {{2020, 7, 30, 5, 52}, 3}, {{2020, 7, 30, 5, 53}, 2}, {{2020, 7, 30, 5, 54}, 3}, {{2020, 7, 30, 5, 55}, 3}, {{2020, 7, 30, 6, 32}, 2}, {{2020, 7, 30, 6, 33}, 3}, {{2020, 7, 30, 6, 34}, 3}, {{2020, 7, 30, 6, 35}, 0}}; colorRange = { Green, Blue, Red, Blue, Blue, Blue, Blue, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Red, Green}; DateListPlot[Partition[data, 1] , AspectRatio -> 0.8/3, Filling -> Axis, FrameTicks -> {Automatic, {{{{2020, 7, 29, 22, 30}, "\!$$\* StyleBox[\"22\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\"30\",\nFontColor->RGBColor[1, 0, 0]]$$"}, {{2020, 7, 29, 23, 00}, "23:00"}, {{2020, 7, 29, 24, 00}, "24:00"}, {{2020, 7, 30, 01, 00}, "01:00"}, {{2020, 7, 30, 02, 00}, "02:00"}, {{2020, 7, 30, 03, 00}, "03:00"}, {{2020, 7, 30, 04, 00}, "04:00"}, {{2020, 7, 30, 05, 00}, "05:00"}, {{2020, 7, 30, 06, 00}, "06:00"}, {{2020, 7, 30, 06, 35}, "\!$$\* StyleBox[\"06\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]$$\!$$\* StyleBox[\"35\",\nFontColor->RGBColor[1, 0, 0]]$$"}}, None}}, ImageSize -> 600, Joined -> False, LabelStyle -> Directive[Black, Bold, 10] , PlotStyle -> colorRange ] 
Posted 6 months ago
 But why does PlotStyle -> {PointSize[.008], #} & /@ colorRange not work?
Posted 6 months ago
 In order to fix the scope of the use of Map you can use parenthesis as follows  PlotStyle -> ({PointSize[0.008], #}& /@ colorRange)