MCPcopy Create free account
hub / github.com/alceal/plotlars / build_regular

Function build_regular

crates/plotlars-plotly/src/subplot_grid/regular.rs:164–355  ·  view source on GitHub ↗
(
    plots: Vec<&dyn Plot>,
    rows: Option<usize>,
    cols: Option<usize>,
    title: Option<Text>,
    h_gap: Option<f64>,
    v_gap: Option<f64>,
    legends: Option<Vec<Option<&CustomLegend>>>,

Source from the content-addressed store, hash-verified

162
163#[allow(clippy::too_many_arguments)]
164pub(super) fn build_regular(
165 plots: Vec<&dyn Plot>,
166 rows: Option<usize>,
167 cols: Option<usize>,
168 title: Option<Text>,
169 h_gap: Option<f64>,
170 v_gap: Option<f64>,
171 legends: Option<Vec<Option<&CustomLegend>>>,
172 dimensions: Option<&Dimensions>,
173) -> SubplotGrid {
174 let rows = rows.unwrap_or(1);
175 let cols = cols.unwrap_or(1);
176 let h_gap = h_gap.unwrap_or(0.1);
177 let v_gap = v_gap.unwrap_or(0.1);
178
179 validate_regular_grid(plots.len(), rows, cols);
180
181 let mut all_traces: Vec<Box<dyn Trace + 'static>> = Vec::new();
182 let mut plot_titles: Vec<Option<Text>> = Vec::new();
183 let mut axis_configs: Vec<(AxisConfig, AxisConfig)> = Vec::new();
184 let mut subplot_info: Vec<NonCartesianLayout> = Vec::new();
185 let mut legend_sources: Vec<Vec<JsonTrace>> = Vec::new();
186 let mut per_plot_traces: Vec<Vec<Box<dyn Trace + 'static>>> = Vec::new();
187 let mut scene_count = 0;
188 let mut polar_count = 0;
189 let mut mapbox_count = 0;
190 let mut geo_count = 0;
191
192 for (plot_idx, plot) in plots.iter().enumerate() {
193 let (traces, layout_json) = convert_plot(*plot);
194 let plot_type = detect_plot_type(traces[0].as_ref());
195
196 plot_titles.push(plot.ir_layout().title.clone());
197
198 let x_axis_json = layout_json.get("xaxis").cloned().unwrap_or(Value::Null);
199 let y_axis_json = layout_json.get("yaxis").cloned().unwrap_or(Value::Null);
200 let layout_fragment = match plot_type {
201 PlotType::Cartesian3D => layout_json.get("scene").cloned(),
202 PlotType::Polar => layout_json.get("polar").cloned(),
203 PlotType::Mapbox => layout_json.get("mapbox").cloned(),
204 PlotType::Geo => layout_json.get("geo").cloned(),
205 _ => None,
206 };
207
208 let x_title = plot
209 .ir_layout()
210 .x_title
211 .clone()
212 .or_else(|| extract_axis_title_from_annotations(&layout_json, true));
213
214 let y_title = plot
215 .ir_layout()
216 .y_title
217 .clone()
218 .or_else(|| extract_axis_title_from_annotations(&layout_json, false));
219
220 let x_config = AxisConfig {
221 title: x_title,

Callers 1

regularMethod · 0.85

Calls 15

validate_regular_gridFunction · 0.85
detect_plot_typeFunction · 0.85
adjust_domain_for_typeFunction · 0.85
create_regular_layoutFunction · 0.85
set_axis_referencesMethod · 0.80
set_scene_referenceMethod · 0.80
set_subplot_referenceMethod · 0.80
set_domainMethod · 0.80
ensure_colorMethod · 0.80

Tested by

no test coverage detected