I want to color each point in ListPlot
using custom markers when there are only values of the points, i.e. the data is in the form {1,2,3,...}
. There are many related questions (e.g. here and here), but the solutions are either to use data in the form {x,y}
, convert it to the list of lists, and then effectively color each subplot separately
data1 = {{{1, 2}, Red}, {{2, 3}, Blue}};
ListPlot[
List /@ data1[[;; , 1]],
PlotMarkers ->
Apply[Graphics[{#, Rectangle[]}, ImageSize -> 15] &, List /@ data1[[;; , 2]], {1}]
]
or to color each point using Style
, in which case using custom markers doesn't work.
data2 = {Style[2, Red], Style[3, Blue]};
ListPlot[data2, PlotMarkers -> Graphics[{Rectangle[]}, ImageSize -> 15]]
Is there a solution when the data doesn't have the x
coordinate?
x
coordinate? $\endgroup$DataRange
doesn't work withx
inserted, so you will need a new workaround there and so on. $\endgroup$