forked from alandefreitas/matplotplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaxes_type.h
More file actions
2894 lines (2273 loc) 路 117 KB
/
Copy pathaxes_type.h
File metadata and controls
2894 lines (2273 loc) 路 117 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Created by Alan Freitas on 2020-07-04.
//
#ifndef MATPLOTPLUSPLUS_AXES_TYPE_H
#define MATPLOTPLUSPLUS_AXES_TYPE_H
#include <matplot/detail/config.h>
#include <matplot/util/colors.h>
#include <matplot/util/handle_types.h>
#include <matplot/util/keywords.h>
#include <matplot/core/axis_type.h>
#include <matplot/core/legend.h>
#include <matplot/core/line_spec.h>
#include <matplot/axes_objects/error_bar.h>
#include <matplot/axes_objects/function_line.h>
#include <matplot/axes_objects/histogram.h>
#include <matplot/axes_objects/line.h>
#include <optional>
namespace matplot {
class MATPLOT_EXPORTS axes_type : public std::enable_shared_from_this<class axes_type> {
public:
// {left bottom right top}
static constexpr std::array<float, 4> default_subplot_inset{.2f, .18f,
.04f, .1f};
// {x, y, width, height}
static constexpr std::array<float, 4> default_axes_position{
.13f, .11f, .775f, .815f};
public:
axes_type();
explicit axes_type(class figure_type *parent);
axes_type(class figure_type *parent, std::array<float, 4> position);
explicit axes_type(figure_handle parent);
axes_type(figure_handle parent, std::array<float, 4> position);
virtual ~axes_type() = default;
public /* functions that operate the axes */:
/// Plot parent figure
void draw();
/// Touch parent figure
void touch();
/// Put an object in the axes
void emplace_object(axes_object_handle obj);
/// Put object derived from axes_object_handle in the axes
template <class T> void emplace_object(std::shared_ptr<T> obj) {
std::enable_if_t<std::is_base_of_v<axes_object, T>,
axes_object_handle>
ah = std::dynamic_pointer_cast<axes_object>(obj);
emplace_object(ah);
}
/// Run commands to plot axes on the parent figure
void run_commands();
void run_draw_commands();
/// Run command on the parent figure
void run_command(const std::string &command);
/// Include a comment on the parent figure (command with #)
void include_comment(const std::string &command);
/// Check the type of axes
bool is_3d();
bool is_3d_map();
bool is_2d();
bool is_polar();
/// Copy clone the axes and put it in another figure
axes_handle copy(figure_handle parent);
/// Child limits (x_min, x_max, y_min, y_max)
std::array<double, 4> child_limits() const;
public /* axes limits and axis ratios */:
/// \brief Sets limits on x-axis and y-axis
void axis(const std::array<double, 4> &limits_x_y);
/// \brief Make axes visible / invisible
void axis(bool v);
/// \brief Make x/y/z-axis limits automatic
void axis(keyword_automatic_type automatic);
/// \brief Make x/y/z-axis limits manual
void axis(keyword_manual_type manual);
/// \brief Reverse y-axis
void axis(keyword_ij_type);
/// \brief Make x/y-axis ratio = 1 by changing the axis limits
void axis(keyword_equal_type);
/// \brief Make x/y/z-axis limits tight from x/y/z-min to x/y/z-max
void axis(keyword_tight_type);
/// \brief Make x/y-axis square with ratio 1 by changing the axes size
void axis(keyword_square_type);
public /* properties */:
const std::array<float, 4> &position() const;
void position(const std::array<float, 4> &position);
float azimuth() const;
void azimuth(float azimuth);
float elevation() const;
void elevation(float elevation);
std::pair<float, float> view() const;
void view(float azimuth, float elevation);
void rotate(float azimuth, float elevation);
const float &x_origin() const;
void x_origin(float x);
const float &y_origin() const;
void y_origin(float y);
const float &width() const;
void width(float w);
const float &height() const;
void height(float h);
const class axis_type &x_axis() const;
class axis_type &x_axis();
std::array<double, 2> xlim() const;
void xlim(const std::array<double, 2> &);
void xlim(keyword_automatic_type);
void xlim(keyword_manual_type);
const std::string &xlabel() const;
void xlabel(std::string_view str);
const std::string &xtickformat() const;
void xtickformat(std::string_view str);
const std::vector<double> &xticks() const;
void xticks(const std::vector<double> &ticks);
const std::vector<std::string> &xticklabels() const;
void xticklabels(const std::vector<std::string> &labels);
void xtickangle(double degrees);
double xtickangle();
const class axis_type &x2_axis() const;
class axis_type &x2_axis();
std::array<double, 2> x2lim() const;
void x2lim(const std::array<double, 2> &);
void x2lim(keyword_automatic_type);
void x2lim(keyword_manual_type);
const std::string &x2label() const;
void x2label(std::string_view str);
const std::string &x2tickformat() const;
void x2tickformat(std::string_view str);
const std::vector<double> &x2ticks() const;
void x2ticks(const std::vector<double> &ticks);
const std::vector<std::string> &x2ticklabels() const;
void x2ticklabels(const std::vector<std::string> &labels);
void x2tickangle(double degrees);
double x2tickangle();
const class axis_type &y_axis() const;
class axis_type &y_axis();
std::array<double, 2> ylim() const;
void ylim(const std::array<double, 2> &);
void ylim(keyword_automatic_type);
void ylim(keyword_manual_type);
const std::string &ylabel() const;
void ylabel(std::string_view str);
const std::string &ytickformat() const;
void ytickformat(std::string_view str);
const std::vector<double> &yticks() const;
void yticks(const std::vector<double> &ticks);
const std::vector<std::string> &yticklabels() const;
void yticklabels(const std::vector<std::string> &labels);
void ytickangle(double degrees);
double ytickangle();
const class axis_type &y2_axis() const;
class axis_type &y2_axis();
std::array<double, 2> y2lim() const;
void y2lim(const std::array<double, 2> &);
void y2lim(keyword_automatic_type);
void y2lim(keyword_manual_type);
const std::string &y2label() const;
void y2label(std::string_view str);
const std::string &y2tickformat() const;
void y2tickformat(std::string_view str);
const std::vector<double> &y2ticks() const;
void y2ticks(const std::vector<double> &ticks);
const std::vector<std::string> &y2ticklabels() const;
void y2ticklabels(const std::vector<std::string> &labels);
void y2tickangle(double degrees);
double y2tickangle();
const class axis_type &z_axis() const;
class axis_type &z_axis();
std::array<double, 2> zlim() const;
void zlim(const std::array<double, 2> &);
void zlim(keyword_automatic_type);
void zlim(keyword_manual_type);
const std::string &zlabel() const;
void zlabel(std::string_view str);
const std::string &ztickformat() const;
void ztickformat(std::string_view str);
const std::vector<double> &zticks() const;
void zticks(const std::vector<double> &ticks);
const std::vector<std::string> &zticklabels() const;
void zticklabels(const std::vector<std::string> &labels);
void ztickangle(double degrees);
double ztickangle();
const class axis_type &cb_axis() const;
class axis_type &cb_axis();
std::array<double, 2> cblim() const;
void cblim(const std::array<double, 2> &);
void cblim(keyword_automatic_type);
void cblim(keyword_manual_type);
const std::string &cblabel() const;
void cblabel(std::string_view str);
const std::string &cbtickformat() const;
void cbtickformat(std::string_view str);
const std::vector<double> &cbticks() const;
void cbticks(const std::vector<double> &ticks);
const std::vector<std::string> &cbticklabels() const;
void cbticklabels(const std::vector<std::string> &labels);
void cbtickangle(double degrees);
double cbtickangle();
bool cb_vertical() const;
void cb_vertical(bool cb_vertical);
bool cb_inside() const;
void cb_inside(bool cb_inside);
const std::array<float, 4> &cb_position() const;
void cb_position(const std::array<float, 4> &cb_position);
const class axis_type &r_axis() const;
class axis_type &r_axis();
std::array<double, 2> rlim() const;
void rlim(const std::array<double, 2> &);
void rlim(keyword_automatic_type);
void rlim(keyword_manual_type);
const std::string &rlabel() const;
void rlabel(std::string_view str);
const std::string &rtickformat() const;
void rtickformat(std::string_view str);
const std::vector<double> &rticks() const;
void rticks(const std::vector<double> &ticks);
const std::vector<std::string> &rticklabels() const;
void rticklabels(const std::vector<std::string> &labels);
void rtickangle(double degrees);
double rtickangle();
const class axis_type &t_axis() const;
class axis_type &t_axis();
std::array<double, 2> tlim() const;
void tlim(const std::array<double, 2> &);
void tlim(keyword_automatic_type);
void tlim(keyword_manual_type);
void t_axis(const class axis_type &t_axis);
bool title_visible() const;
void title_visible(bool title_visible);
bool visible() const;
void visible(bool visible);
void limits_mode(keyword_automatic_type automatic);
void limits_mode(keyword_manual_type manual);
void limits_mode_automatic(bool automatic);
bool limits_mode_automatic() const;
void limits_mode_manual(bool automatic);
bool limits_mode_manual() const;
const std::string &title() const;
void title(std::string_view title);
bool title_enhanced() const;
void title_enhanced(bool title_enhanced);
bool axes_aspect_ratio_auto() const;
void axes_aspect_ratio_auto(bool axes_aspect_ratio_auto);
float axes_aspect_ratio() const;
void axes_aspect_ratio(float x);
const std::string &font() const;
void font(std::string_view font);
float font_size() const;
void font_size(float font_size);
const std::string &font_weight() const;
void font_weight(std::string_view font_weight);
bool clipping() const;
void clipping(bool clipping);
float label_font_size_multiplier() const;
void label_font_size_multiplier(float label_font_size_multiplier);
float title_font_size_multiplier() const;
void title_font_size_multiplier(float title_font_size_multiplier);
const std::string &title_font_weight() const;
void title_font_weight(std::string_view title_font_weight);
const color_array &title_color() const;
void title_color(const color_array &title_color);
const color_array &color() const;
void color(const color_array &color);
void color(const std::array<float, 3> &color);
void color(std::string_view c);
void color(const enum color &c);
const std::vector<color_array> &colororder() const;
void colororder(const std::vector<color_array> &colororder);
template <class T> void colororder(const std::vector<T> &order) {
std::vector<color_array> cs;
for (const auto &c : order) {
cs.emplace_back(to_array(c));
}
colororder(cs);
}
size_t colororder_index() const;
void colororder_index(size_t colororder_index);
void bump_colororder_index();
color_array get_color_and_bump();
const color_array grid_color() const;
void grid_color(const color_array &grid_color);
float grid_alpha() const;
void grid_alpha(float grid_alpha);
bool handle_visibility() const;
void handle_visibility(bool handle_visibility);
float minor_grid_alpha() const;
void minor_grid_alpha(float minor_grid_alpha);
bool minor_grid_alpha_mode() const;
void minor_grid_alpha_mode(bool minor_grid_alpha_mode);
const color_array minor_grid_color() const;
void minor_grid_color(const color_array &minor_grid_color);
line_spec minor_grid_line_style() const;
void minor_grid_line_style(line_spec minor_grid_line_style);
bool grid() const;
void grid(bool grid);
bool minor_grid() const;
void minor_grid(bool minor_grid);
bool x_grid() const;
void x_grid(bool x_grid);
bool x_minor_grid() const;
void x_minor_grid(bool x_minor_grid);
bool y_grid() const;
void y_grid(bool y_grid);
bool y_minor_grid() const;
void y_minor_grid(bool y_minor_grid);
bool z_grid() const;
void z_grid(bool z_grid);
bool z_minor_grid() const;
void z_minor_grid(bool z_minor_grid);
bool r_grid() const;
void r_grid(bool r_grid);
bool r_minor_grid() const;
void r_minor_grid(bool r_minor_grid);
line_spec grid_line_style() const;
void grid_line_style(line_spec grid_line_style);
const std::string &line_style_order() const;
void line_style_order(std::string_view line_style_order);
size_t line_style_order_index() const;
void line_style_order_index(size_t line_style_order_index);
float line_width() const;
void line_width(float line_width);
bool next_plot_replace() const;
void next_plot_replace(bool next_plot_replace);
bool hold() const;
void hold(bool v);
const std::vector<std::shared_ptr<axes_object>> &children() const;
void
children(const std::vector<std::shared_ptr<axes_object>> &children);
void clear();
const legend_handle &legend() const;
void legend(const legend_handle &legend);
void legend(const std::vector<std::string> &names);
bool box() const;
void box(bool box);
bool box_full() const;
void box_full(bool box);
const std::vector<std::vector<double>> &colormap() const;
void colormap(const std::vector<std::vector<double>> &colormap);
color_array colormap_interpolation(double value, double min,
double max);
size_t max_colors() const;
void max_colors(size_t max_colors);
bool color_box() const;
void color_box(bool color_box);
const std::pair<double, double> color_box_range() const;
void color_box_range(const std::pair<double, double> &color_box_range);
void color_box_range(double cb_min, double cb_max);
bool color_box_log_scale() const;
void color_box_log_scale(bool color_box_log_scale);
bool grid_front() const;
void grid_front(bool grid_front);
const class figure_type *parent() const;
class figure_type *parent();
void parent(class figure_type *);
public /* create plots on the axes */:
/// Create simple line plot
line_handle plot(const std::vector<double> &x,
const std::vector<double> &y,
std::string_view line_spec = "");
/// Create line plot with automatic x = 1,2,...,n
line_handle plot(const std::vector<double> &y,
std::string_view line_spec = "");
/// \brief Create many line plots at once with parameter pack
/// First two parameters are always 1) x and y or 2) y and line spec
/// If first two parameters are x and y, third parameter might be:
/// 1a) the line spec or 1b) the x2 for the next plot
/// If first two parameters are y and line spec, third parameter might
/// be:
/// 2a) the x2 for next plot (case 1 for next plot) or
/// 2b) the y for next plot (case 2 for next plot)
/// This function represents the case 1a, where 3rd parameter line spec
/// is a divider between plots
template <class... Args>
auto plot(const std::vector<double> &x, const std::vector<double> &y,
std::string_view line_spec, Args &&...args) {
std::vector<line_handle> result;
std::vector<line_handle> result_a =
vectorize(this->plot(x, y, line_spec));
bool p = this->next_plot_replace();
this->next_plot_replace(false);
std::vector<line_handle> result_b =
vectorize(this->plot(std::forward<Args>(args)...));
this->next_plot_replace(p);
result.insert(result.end(), result_a.begin(), result_a.end());
result.insert(result.end(), result_b.begin(), result_b.end());
return result;
}
/// \brief Create many line plots at once with parameter pack
/// First two parameters are always 1) x and y or 2) y and line spec
/// If first two parameters are x and y, third parameter might be:
/// 1a) the line spec or 1b) the x2 for the next plot
/// If first two parameters are y and line spec, third parameter might
/// be:
/// 2a) the x2 for next plot (case 1 for next plot) or
/// 2b) the y for next plot (case 2 for next plot)
/// This function represents the case 1b, where 3rd parameter x2 is a
/// divider between plots
template <class... Args>
auto plot(const std::vector<double> &x, const std::vector<double> &y,
const std::vector<double> &x2, Args &&...args) {
std::vector<line_handle> result;
std::vector<line_handle> result_a = vectorize(this->plot(x, y));
bool p = this->next_plot_replace();
this->next_plot_replace(false);
std::vector<line_handle> result_b =
vectorize(this->plot(x2, std::forward<Args>(args)...));
this->next_plot_replace(p);
result.insert(result.end(), result_a.begin(), result_a.end());
result.insert(result.end(), result_b.begin(), result_b.end());
return result;
}
/// \brief Create many line plots at once with parameter pack
/// First two parameters are always 1) x and y or 2) y and line spec
/// If first two parameters are x and y, third parameter might be:
/// 1a) the line spec or 1b) the x2 for the next plot
/// If first two parameters are y and line spec, third parameter might
/// be:
/// 2a) the x2 for next plot (case 1 for next plot) or
/// 2b) the y for next plot (case 2 for next plot)
/// This function represents the case 2, where 2nd parameter line spec
/// is a divider between plots
template <class... Args>
auto plot(const std::vector<double> &y, std::string_view line_spec,
Args &&...args) {
std::vector<line_handle> result;
std::vector<line_handle> result_a =
vectorize(this->plot(y, line_spec));
bool p = this->next_plot_replace();
this->next_plot_replace(false);
std::vector<line_handle> result_b =
vectorize(this->plot(std::forward<Args>(args)...));
this->next_plot_replace(p);
result.insert(result.end(), result_a.begin(), result_a.end());
result.insert(result.end(), result_b.begin(), result_b.end());
return result;
}
/// Plot lists of lists
std::vector<line_handle> plot(const std::vector<double> &x,
const std::vector<std::vector<double>> &Y,
std::string_view line_spec = "");
/// Plot lists of lists with automatic x
std::vector<line_handle> plot(const std::vector<std::vector<double>> &Y,
std::string_view line_spec = "");
/// Plot lines representing a colormap
std::vector<line_handle>
rgbplot(const std::vector<std::vector<double>> &colormap);
/// Plot 3d line plot
line_handle plot3(const std::vector<double> &x,
const std::vector<double> &y,
const std::vector<double> &z,
std::string_view line_spec = "");
/// Plot 3d line plot - lists of Xs and Ys
std::vector<line_handle>
plot3(const std::vector<std::vector<double>> &X,
const std::vector<std::vector<double>> &Y,
const std::vector<double> &z, std::string_view line_spec = "");
/// 3d-plot lists of Xs, Ys, and Zs
std::vector<line_handle>
plot3(const std::vector<std::vector<double>> &X,
const std::vector<std::vector<double>> &Y,
const std::vector<std::vector<double>> &Z,
std::string_view line_spec = "");
/// \brief Create many 3d line plots at once with parameter pack
/// The logic is the analogous to the plot function:
/// Case 1a: x, y, z, line_spec, next_x, ...
/// Case 1b: x, y, z, next_x, ...
/// Case 2: z, line_spec, next_x, ...
/// This function represents case 1a
template <class... Args>
auto plot3(const std::vector<double> &x, const std::vector<double> &y,
const std::vector<double> &z, std::string_view line_spec,
Args &&...args) {
std::vector<line_handle> result;
std::vector<line_handle> result_a =
vectorize(this->plot3(x, y, z, line_spec));
bool p = this->next_plot_replace();
this->next_plot_replace(false);
std::vector<line_handle> result_b =
vectorize(this->plot3(std::forward<Args>(args)...));
this->next_plot_replace(p);
result.insert(result.end(), result_a.begin(), result_a.end());
result.insert(result.end(), result_b.begin(), result_b.end());
return result;
}
/// \brief Create many 3d line plots at once with parameter pack
/// The logic is the analogous to the plot function:
/// Case 1a: x, y, z, line_spec, next_x, ...
/// Case 1b: x, y, z, next_x, ...
/// Case 2: z, line_spec, next_x, ...
/// This function represents case 1b
template <class... Args>
auto plot3(const std::vector<double> &x, const std::vector<double> &y,
const std::vector<double> &z, const std::vector<double> &x2,
Args &&...args) {
std::vector<line_handle> result;
std::vector<line_handle> result_a = vectorize(this->plot3(x, y, z));
bool p = this->next_plot_replace();
this->next_plot_replace(false);
std::vector<line_handle> result_b =
vectorize(this->plot3(x2, std::forward<Args>(args)...));
this->next_plot_replace(p);
result.insert(result.end(), result_a.begin(), result_a.end());
result.insert(result.end(), result_b.begin(), result_b.end());
return result;
}
/// Create stairs line plot
stair_handle stairs(const std::vector<double> &x,
const std::vector<double> &y,
std::string_view line_spec = "");
/// Basic stairs function with automatic x
stair_handle stairs(const std::vector<double> &y,
std::string_view line_spec = "");
/// Stairs with lists of lists (same x for all Y)
std::vector<stair_handle>
stairs(const std::vector<double> &x,
const std::vector<std::vector<double>> &Y,
std::string_view line_spec = "");
/// Stairs with lists of lists (one X per Y)
std::vector<stair_handle>
stairs(const std::vector<std::vector<double>> &X,
const std::vector<std::vector<double>> &Y,
std::string_view line_spec = "");
/// Stairs with lists of lists with automatic x
std::vector<stair_handle>
stairs(const std::vector<std::vector<double>> &Y,
std::string_view line_spec = "");
/// \brief Create many stairs at once with parameter pack
/// The logic is analogous to the plot function:
/// Case 1a: x, y, line_spec, next_x
/// Case 1b: x, y, next_x
/// Case 2 : y, line_spec, next_x
/// This function represents case 1a
template <class... Args>
auto stairs(const std::vector<double> &x, const std::vector<double> &y,
std::string_view line_spec, Args &&...args) {
std::vector<stair_handle> result;
std::vector<stair_handle> result_a =
vectorize(this->stairs(x, y, line_spec));
bool p = this->next_plot_replace();
this->next_plot_replace(false);
std::vector<stair_handle> result_b =
vectorize(this->stairs(std::forward<Args>(args)...));
this->next_plot_replace(p);
result.insert(result.end(), result_a.begin(), result_a.end());
result.insert(result.end(), result_b.begin(), result_b.end());
return result;
}
/// \brief Create many stairs at once with parameter pack
/// The logic is analogous to the plot function:
/// Case 1a: x, y, line_spec, next_x
/// Case 1b: x, y, next_x
/// Case 2 : y, line_spec, next_x
/// This function represents case 1b
template <class... Args>
auto stairs(const std::vector<double> &x, const std::vector<double> &y,
const std::vector<double> &x2, Args &&...args) {
std::vector<stair_handle> result;
std::vector<stair_handle> result_a = vectorize(this->stairs(x, y));
bool p = this->next_plot_replace();
this->next_plot_replace(false);
std::vector<stair_handle> result_b =
vectorize(this->stairs(x2, std::forward<Args>(args)...));
this->next_plot_replace(p);
result.insert(result.end(), result_a.begin(), result_a.end());
result.insert(result.end(), result_b.begin(), result_b.end());
return result;
}
/// \brief Create many stairs at once with parameter pack
/// The logic is analogous to the plot function:
/// Case 1a: x, y, line_spec, next_x
/// Case 1b: x, y, next_x
/// Case 2 : y, line_spec, next_x
/// This function represents case 2
template <class... Args>
auto stairs(const std::vector<double> &y, std::string_view line_spec,
Args &&...args) {
std::vector<stair_handle> result;
std::vector<stair_handle> result_a =
vectorize(this->stairs(y, line_spec));
bool p = this->next_plot_replace();
this->next_plot_replace(false);
std::vector<stair_handle> result_b =
vectorize(this->stairs(std::forward<Args>(args)...));
this->next_plot_replace(p);
result.insert(result.end(), result_a.begin(), result_a.end());
result.insert(result.end(), result_b.begin(), result_b.end());
return result;
}
/// Core errorbar function
error_bar_handle
errorbar(const std::vector<double> &x, const std::vector<double> &y,
const std::vector<double> &error,
error_bar::type type = error_bar::type::vertical,
std::string_view line_spec = "");
/// Core errorbar function with different values on both directions
error_bar_handle errorbar(const std::vector<double> &x,
const std::vector<double> &y,
const std::vector<double> &y_neg_delta,
const std::vector<double> &y_pos_delta,
const std::vector<double> &x_neg_delta,
const std::vector<double> &x_pos_delta,
std::string_view line_spec = "");
/// If there is a string instead of a type the first version, we default
/// to vertical
error_bar_handle errorbar(const std::vector<double> &x,
const std::vector<double> &y,
const std::vector<double> &y_error,
std::string_view line_spec);
/// Core area function (x is a vector, y is a matrix)
std::vector<filled_area_handle>
area(const std::vector<double> &x,
const std::vector<std::vector<double>> &Y, double base_value = 0.,
bool stacked = true, std::string_view line_spec = "k-");
/// Area: x is a vector, y is a vector
filled_area_handle area(const std::vector<double> &x,
const std::vector<double> &y,
double base_value = 0., bool stacked = true,
std::string_view line_spec = "k-");
/// Area: Automatic x, y is a matrix
std::vector<filled_area_handle>
area(const std::vector<std::vector<double>> &Y, double base_value = 0.,
bool stacked = true, std::string_view line_spec = "k-");
/// Area: Skip the base value
std::vector<filled_area_handle>
area(const std::vector<std::vector<double>> &Y, bool stacked,
std::string_view line_spec = "k-");
/// Area: Automatic x, y is a vector
filled_area_handle area(const std::vector<double> &y,
double base_value = 0., bool stacked = true,
std::string_view line_spec = "k-");
/// String function line plot
string_function_handle fplot(std::string_view equation,
std::string_view line_spec = "");
/// String function line plots
std::vector<string_function_handle>
fplot(std::vector<std::string> equations,
std::vector<std::string> line_specs = {});
/// Lambda function line plot
function_line_handle fplot(function_line::function_type equation,
const std::array<double, 2> &x_range = {-5,
5},
std::string_view line_spec = "");
/// Lambda function line plot - automatic limits
function_line_handle fplot(function_line::function_type equation,
std::string_view line_spec);
/// Lambda function line plot - two functions (x/y)
function_line_handle fplot(function_line::function_type function_x,
function_line::function_type function_y,
const std::array<double, 2> &t_range = {-5,
5},
std::string_view line_spec = "");
/// Lambda function line plot - list of functions
std::vector<function_line_handle>
fplot(const std::vector<function_line::function_type> &equations,
const std::array<double, 2> &x_range = {-5, 5},
const std::vector<std::string> &line_specs = {});
/// Lambda function line plot - list of functions and line specs
std::vector<function_line_handle>
fplot(const std::vector<function_line::function_type> &equations,
const std::vector<double> &x_range,
const std::vector<std::string> &line_specs = {});
using implicit_function_type = std::function<double(double, double)>;
/// Implicit lambda function line plot (one-level={0} contour)
line_handle
fimplicit(implicit_function_type equation,
const std::array<double, 4> &xy_interval = {-5, 5, -5, 5},
std::string_view line_spec = "");
/// Implicit lambda function line plot - automatic xy_interval