Closed
Description
Description
I tried to combine two point density charts that share their coloraxis. For heatmaps this does not seems to be a problem, but for point density charts you have to (i) align the coloraxis, and (ii) set the contours individually.
Repro steps
code
#r "nuget: Plotly.NET.Interactive"
open Plotly.NET
open Plotly.NET.LayoutObjects
open Plotly.NET.TraceObjects
open Plotly.NET.StyleParam
let getZeroCollection n : float []=
Array.zeroCreate n
[
Chart.PointDensity(
x=(getZeroCollection 100),
y=(getZeroCollection 100)
)
|> Chart.withColorAxisAnchor(1)
Chart.PointDensity(
x = (getZeroCollection 50),
y = (getZeroCollection 50)
)
|> Chart.withColorAxisAnchor(1)
]
|> Chart.Grid(2,1)
The inner circle of the second chart has a point density of 50, but the color scale indicates 100.
Known workarounds
By setting the contour ranges for each plot individually and setting the ColorAxis to the same range, the combined plot is correct:
[
Chart.PointDensity(
x=(getZeroCollection 100),
y=(getZeroCollection 100)
)
|> Chart.withColorAxisAnchor(1)
|> GenericChart.mapiTrace (fun i t -> if i = 0 then t?contours <- (Contours.init(Start = 0, End = 100)); t else t)
Chart.PointDensity(
x = (getZeroCollection 50),
y = (getZeroCollection 50)
)
|> Chart.withColorAxisAnchor(1)
|> GenericChart.mapiTrace (fun i t -> if i = 0 then t?contours <- (Contours.init(Start = 0, End = 100)); t else t)
]
|> Chart.Grid(2,1)
|> Chart.withColorAxis(colorAxis=ColorAxis.init(CMin=0.,CMax=70.),Id=SubPlotId.ColorAxis 1)
Solution
- The easiest solution is to add an option to either
Chart.Grid
orChart.withLayoutStyle
that enables to share the color axis for each density point chart. - If that is not possible,
contours
should be accessible fromChart.PointDensity()