Stats

Popular Posts

Followers

ListPlot with Colormap

戴忠淵 於 Friday, June 30, 2017 8:26 PM 發表

mylistplot[data_, xrange_, yrange_, pointsize_, colormap_, imagesize_] := 
  Module[{colors, styledData}, 
    colors = ColorData[colormap] /@ Rescale[data[[All, 2]], yrange];
    styledData = Style[#, colors[[#2]]] & @@@ Transpose[{data, Range[Length[data]]}];
    ListPlot[
      styledData, 
      PlotTheme -> "Detailed", 
      PlotStyle -> PointSize[pointsize], 
      PlotRange -> {xrange, yrange}, 
      Frame -> True, 
      ImageSize -> imagesize*GoldenRatio,
      PlotLegends -> Placed[
        BarLegend[{colormap, yrange}, LegendMarkerSize -> imagesize, 
        LegendMargins -> {{0, 0}, {0, 0}}],Right
      ]
    ]
  ]


mylistplot[iris, {2, 4}, {0, 2.5}, 0.015, "TemperatureMap", 225]

Tags: ,

讀者回應 ( 0 意見 )

Post a Comment

Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.

如果這篇文章對你有幫助,那請留個訊息給我~