Nazar Pohonchuk
04/02/2023, 11:37 AMMap<OpenEndRange<Double>, Int>
, where keys are openEndRange of double and values are how many numbers are in those ranges. (I attached screenshots.) I change this map to look like this {Ranges=[0.0, 0.75, 1.5, 2.25, 3.0, 3.75, 4.5, 5.25], Values=[17, 6, 13, 27, 11, 8, 14, 4]}
(it's dataBar variable), where in "Ranges" only start points of the range. I am trying to use lets-plot in Jupyter Notebook for creating a histogram when on the x-axis will be ranges and on the y-axis will be how many numbers are in those ranges. But it doesn't look like how I expected.
Could anyone help me, please? Or give some learning materials on lets-plot? Or maybe you would recommend another library for creating histograms?Nazar Pohonchuk
04/02/2023, 12:37 PMPlotly.plot {
bar {
@OptIn(ExperimentalStdlibApi::class)
x(*rangeToCount.keys.map {it.toString()}.toTypedArray())
@OptIn(ExperimentalStdlibApi::class)
y(*rangeToCount.values.toTypedArray())
}
}.makeFile()
But still, I will be thankful If you can explain why I can't do the same in lets-plotNazar Pohonchuk
04/02/2023, 12:39 PMAndrei Kislitsyn
04/02/2023, 12:49 PMgeomBar()
uses “count” stat by default (i.e. does not use the user-defined values as y, but rather counts the number of observations for each x), so in your example, you need to specify “identity” as a stat.
2. Since lets-plot does not support ranges as a data type, you need to cast them to a String
manuallyNazar Pohonchuk
04/02/2023, 1:05 PM