Open
Description
Is it possible to create a unique color scale that does not depend on the objects on the graph? The thing is that I just color the objects using my own linear interpolation, so I just need to specify the scale itself. Can I create it separately and place it anywhere?
fn custom_result(
result: &Matrix<f32, Dyn, Const<1>, VecStorage<f32, Dyn, Const<1>>>,
triangles: &Vec<Elist>,
nodes: &Vec<Nlist>,
gradient: &LinearGradient,
plot: &mut Plot,
) {
let T_MAX = result.max();
let T_MIN = result.min();
for elem in triangles {
let node_i = &nodes[elem.node_i - 1];
let node_j = &nodes[elem.node_j - 1];
let node_k = &nodes[elem.node_k - 1];
let T1 = result[node_i.node - 1];
let T2 = result[node_j.node - 1];
let T3 = result[node_k.node - 1];
let temperature = (T1 + T2 + T3) / 3.0;
let trace = Scatter::new(
vec![node_i.x, node_j.x, node_k.x],
vec![node_i.y, node_j.y, node_k.y],
)
.x_axis("x2")
.y_axis("y2")
.mode(Mode::None)
.name(temperature.to_string())
.show_legend(false)
.fill_color(
gradient
.at(interpolate(temperature, T_MIN, T_MAX))
.to_hex_string(),
)
.fill(Fill::ToSelf);
plot.add_trace(trace);
}
}
Metadata
Metadata
Assignees
Labels
No labels