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]
ListPlot with Colormap
由 戴忠淵 於 2017年6月30日星期五
下午8:26 發表
讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~