Open KeesBleijenberg opened 2 weeks ago
There's a couple of ways. You can set the scatterTransform
for the plot to be something like const (scale 0.3)
:
scatterPlot mydata1 $ do
key "my data"
scatterTransform .= const (scaling 0.3)
Or you can manually edit the plotMarker
scatterPlot mydata1 $ do
key "my data"
plotMarker %= scale 0.3
(I haven't tested these out but I think both should work)
Thank you! Both methods work I don't know enough about the Lens library and that's a problem trying to understand Plots
Sorry, a final question. How do I change the border color of the points in a scatter plot? For now they are small orange circles with a thick white border. Or alternatively, how do I remove the border for all points?
a problem trying to understand Plots
Yes, I kinda wanted to see how far you could take. I think the library API actually turned out quite powerful but it does need quite extensive lens knowledge to use it all.
To just remove the lines I think this should work by changing the markerStyle
and setting the line width:
scatterPlot mydata1 $ do
key "my data"
markerStyle %= lw 0
There is also markerStyleFunction
which takes the designated plot colour so you could set the line colour to that too (this example is abusing the semigroup instance for functions) (this might not work because of the ordering):
scatterPlot mydata1 $ do
key "my data"
markerStyleFunction <>= \plotColour -> lc plotColour
-- or set it expicitly
-- markerStyleFunction .= \plotColour -> mempty # fc plotColour # lc plotColour
Again, I haven't tested these.
I tried: markerStyle %= lw 0 -> does compile, but still every point in the plot has a thick white border markerStyleFunction <>= \plotColour -> lc plotColour does not compile:
/home/kees/pvStats/src/PlotGraph.hs:40:13: error: [GHC-83865]
• Couldn't match type: Style V2 Double
with: a0 -> a0
Expected: ASetter'
(Plot (ScatterOptions V2 Double (Point V2 Double)) B)
(Colour Double -> a0 -> a0)
Actual: LensLike'
Identity
(Plot (ScatterOptions V2 Double (Point V2 Double)) B)
(Colour Double
-> Style
(V (Plot (ScatterOptions V2 Double (Point V2 Double)) B))
(N (Plot (ScatterOptions V2 Double (Point V2 Double)) B)))
• In the first argument of ‘(<>=)’, namely ‘markerStyleFunction’
In a stmt of a 'do' block:
markerStyleFunction <>= \ plotColour -> lc plotColour
In the second argument of ‘($)’, namely
‘do key "Opbrengst"
markerStyleFunction <>= \ plotColour -> lc plotColour’
|
40 | markerStyleFunction <>= \plotColour -> lc plotColour
| ^^^^^^^^^^^^^^^^^^^
Error: [S-7282]
Stack failed to execute the build plan.
While executing the build plan, Stack encountered the error:
[S-7011]
While building package pvStats-0.1.0.0 (scroll up to its section to see the error) using:
/home/kees/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_HwdwpEmb_3.10.3.0_ghc-9.6.6 --verbose=1 --builddir=.stack-work/dist/x86_64-linux-tinfo6/ghc-9.6.6 build lib:pvStats exe:pvStats-exe --ghc-options ""
Finally markerStyleFunction .= \plotColour -> mempty # fc plotColour # lc plotColour does compile and works. Thanks!
I want to create a scatter plot with a lot of points. In the first attempt the points overlap each other. Therefor I want to make the points a lot smaller. But how? Kees