Skip to content

Commit b9b7fe4

Browse files
changed name of magnitudes to colors
1 parent 5935aec commit b9b7fe4

File tree

4 files changed

+45
-44
lines changed

4 files changed

+45
-44
lines changed

source/matplot/axes_objects/vectors.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ namespace matplot {
4141
const std::vector<double> &y_data,
4242
const std::vector<double> &u_data,
4343
const std::vector<double> &v_data,
44-
const std::vector<double> &m_data,
44+
const std::vector<double> &c_data,
4545
std::string_view line_spec)
4646
: axes_object(parent), line_spec_(this, line_spec), y_data_(y_data),
47-
x_data_(x_data), u_data_(u_data), v_data_(v_data), m_data_(m_data) {}
47+
x_data_(x_data), u_data_(u_data), v_data_(v_data), c_data_(c_data) {}
4848

4949
vectors::vectors(class axes_type *parent, const std::vector<double> &x_data,
5050
const std::vector<double> &y_data,
@@ -63,20 +63,20 @@ namespace matplot {
6363
const std::vector<double> &u_data,
6464
const std::vector<double> &v_data,
6565
const std::vector<double> &w_data,
66-
const std::vector<double> &m_data,
66+
const std::vector<double> &c_data,
6767
std::string_view line_spec)
6868
: axes_object(parent), line_spec_(this, line_spec), y_data_(y_data),
6969
x_data_(x_data), z_data_(z_data), u_data_(u_data), v_data_(v_data),
70-
w_data_(w_data), m_data_(m_data) {}
70+
w_data_(w_data), c_data_(c_data) {}
7171

7272
std::string vectors::plot_string() {
7373
maybe_update_line_spec();
7474
std::stringstream ss;
7575
ss << " '-' with vectors";
76-
if (!m_data_.empty()) {
76+
if (!c_data_.empty()) {
7777
ss << " linecolor palette";
7878
ss << " linewidth " << line_spec_.line_width();
79-
79+
8080
switch (line_spec_.line_style()) {
8181
case line_spec::line_style::solid_line:
8282
ss << " dashtype 1";
@@ -123,7 +123,7 @@ namespace matplot {
123123
double u_value = u_data_.size() > i ? u_data_[i] : 0;
124124
double v_value = v_data_.size() > i ? v_data_[i] : 0;
125125
double w_value = w_data_.size() > i ? w_data_[i] : 0;
126-
double m_value = m_data_.size() > i ? m_data_[i] : 0;
126+
double c_value = c_data_.size() > i ? c_data_[i] : 0;
127127

128128
bool is_end_of_series =
129129
!std::isfinite(x_value) || !std::isfinite(y_value) ||
@@ -143,9 +143,10 @@ namespace matplot {
143143
}
144144

145145
if (normalize_) {
146-
double mag = std::sqrt(u_value * u_value + v_value * v_value +
147-
w_value * w_value);
148-
if (mag != 0.0) {
146+
double mag =
147+
std::sqrt(u_value * u_value + v_value * v_value +
148+
w_value * w_value);
149+
if (mag != 0.0) {
149150
u_value *= scale_ / mag;
150151
v_value *= scale_ / mag;
151152
w_value *= scale_ / mag;
@@ -159,8 +160,8 @@ namespace matplot {
159160
} else if (parent_->is_3d()) {
160161
ss << " " << 0.0;
161162
}
162-
if (!m_data_.empty()) {
163-
ss << " " << m_value;
163+
if (!c_data_.empty()) {
164+
ss << " " << c_value;
164165
}
165166

166167
ss << "\n";
@@ -181,7 +182,7 @@ namespace matplot {
181182
}
182183

183184
void vectors::maybe_update_line_spec() {
184-
if (!line_spec_.user_color() && m_data_.empty()) {
185+
if (!line_spec_.user_color() && c_data_.empty()) {
185186
auto c = parent_->get_color_and_bump();
186187
line_spec_.color(c);
187188
} else if (line_spec_.has_non_custom_marker() &&

source/matplot/axes_objects/vectors.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ namespace matplot {
4545
const std::vector<double> &v_data,
4646
std::string_view line_spec = "");
4747

48-
/// \brief Create 2D vectors with custom origin and magnitude colors
48+
/// \brief Create 2D vectors with custom origin and colors
4949
vectors(class axes_type *parent, const std::vector<double> &x_data,
5050
const std::vector<double> &y_data,
5151
const std::vector<double> &u_data,
5252
const std::vector<double> &v_data,
53-
const std::vector<double> &m_data,
53+
const std::vector<double> &c_data,
5454
std::string_view line_spec = "");
5555

5656
/// \brief Create 3D vectors with custom origin
@@ -62,14 +62,14 @@ namespace matplot {
6262
const std::vector<double> &w_data,
6363
std::string_view line_spec = "");
6464

65-
/// \brief Create 3D vectors with custom origin and magnitude colors
65+
/// \brief Create 3D vectors with custom origin and colors
6666
vectors(class axes_type *parent, const std::vector<double> &x_data,
6767
const std::vector<double> &y_data,
6868
const std::vector<double> &z_data,
6969
const std::vector<double> &u_data,
7070
const std::vector<double> &v_data,
7171
const std::vector<double> &w_data,
72-
const std::vector<double> &m_data,
72+
const std::vector<double> &c_data,
7373
std::string_view line_spec = "");
7474

7575
/// If we receive an axes_handle, we can convert it to a raw
@@ -224,8 +224,8 @@ namespace matplot {
224224
std::vector<double> v_data_{};
225225
std::vector<double> w_data_{};
226226

227-
/// Vector magnitude
228-
std::vector<double> m_data_{};
227+
/// Vector color mapping values
228+
std::vector<double> c_data_{};
229229

230230
/// Positions at which we want markers to appear
231231
std::vector<size_t> marker_indices_{};

source/matplot/core/axes_type.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4526,7 +4526,7 @@ namespace matplot {
45264526
const std::vector<double> &y,
45274527
const std::vector<double> &u,
45284528
const std::vector<double> &v,
4529-
const std::vector<double> &m, double scale,
4529+
const std::vector<double> &c, double scale,
45304530
std::string_view line_spec) {
45314531
axes_silencer temp_silencer_{this};
45324532

@@ -4562,7 +4562,7 @@ namespace matplot {
45624562
: v;
45634563

45644564
vectors_handle l = std::make_shared<class vectors>(
4565-
this, x, y, u_scaled, v_scaled, m, line_spec);
4565+
this, x, y, u_scaled, v_scaled, c, line_spec);
45664566
l->scale(scale);
45674567
this->emplace_object(l);
45684568
return l;
@@ -4573,14 +4573,14 @@ namespace matplot {
45734573
const std::vector<std::vector<double>> &y,
45744574
const std::vector<std::vector<double>> &u,
45754575
const std::vector<std::vector<double>> &v,
4576-
const std::vector<std::vector<double>> &m,
4576+
const std::vector<std::vector<double>> &c,
45774577
double scale, std::string_view line_spec) {
45784578
return this->quiver(flatten(x), flatten(y), flatten(u), flatten(v),
4579-
(m.empty()) ? std::vector<double>{} : flatten(m),
4579+
(c.empty()) ? std::vector<double>{} : flatten(c),
45804580
scale, line_spec);
45814581
}
45824582

4583-
/// Quiver - 2d x,y,u,v with no magnitude
4583+
/// Quiver - 2d x,y,u,v with no color mapping
45844584
vectors_handle axes_type::quiver(const std::vector<std::vector<double>> &x,
45854585
const std::vector<std::vector<double>> &y,
45864586
const std::vector<std::vector<double>> &u,
@@ -4590,7 +4590,7 @@ namespace matplot {
45904590
scale, line_spec);
45914591
}
45924592

4593-
/// Quiver - x,y,u,v with magnitude
4593+
/// Quiver - x,y,u,v
45944594
vectors_handle axes_type::quiver(const std::vector<double> &x,
45954595
const std::vector<double> &y,
45964596
const std::vector<double> &u,
@@ -4605,7 +4605,7 @@ namespace matplot {
46054605
const std::vector<double> &x, const std::vector<double> &y,
46064606
const std::vector<double> &z, const std::vector<double> &u,
46074607
const std::vector<double> &v, const std::vector<double> &w,
4608-
const std::vector<double> &m, double scale,
4608+
const std::vector<double> &c, double scale,
46094609
std::string_view line_spec) {
46104610
axes_silencer temp_silencer_{this};
46114611

@@ -4656,7 +4656,7 @@ namespace matplot {
46564656
: w;
46574657

46584658
vectors_handle l = std::make_shared<class vectors>(
4659-
this, x, y, z, u_scaled, v_scaled, w_scaled, m, line_spec);
4659+
this, x, y, z, u_scaled, v_scaled, w_scaled, c, line_spec);
46604660
l->scale(scale);
46614661
this->emplace_object(l);
46624662

@@ -4670,16 +4670,16 @@ namespace matplot {
46704670
const std::vector<std::vector<double>> &u,
46714671
const std::vector<std::vector<double>> &v,
46724672
const std::vector<std::vector<double>> &w,
4673-
const std::vector<std::vector<double>> &m,
4673+
const std::vector<std::vector<double>> &c,
46744674
double scale,
46754675
std::string_view line_spec) {
46764676
return this->quiver3(flatten(x), flatten(y), flatten(z), flatten(u),
46774677
flatten(v), flatten(w),
4678-
(m.empty()) ? std::vector<double>{} : flatten(m),
4678+
(c.empty()) ? std::vector<double>{} : flatten(c),
46794679
scale, line_spec);
46804680
}
46814681

4682-
/// Quiver 3d - 2d vectors with no magnitude
4682+
/// Quiver 3d - 2d vectors with no color mapping
46834683
vectors_handle axes_type::quiver3(const std::vector<std::vector<double>> &x,
46844684
const std::vector<std::vector<double>> &y,
46854685
const std::vector<std::vector<double>> &z,
@@ -4697,17 +4697,17 @@ namespace matplot {
46974697
const std::vector<std::vector<double>> &u,
46984698
const std::vector<std::vector<double>> &v,
46994699
const std::vector<std::vector<double>> &w,
4700-
const std::vector<std::vector<double>> &m,
4700+
const std::vector<std::vector<double>> &c,
47014701
double scale,
47024702
std::string_view line_spec) {
47034703
auto [n, p] = size(z);
47044704
vector_1d x = iota(1., static_cast<double>(p));
47054705
vector_1d y = iota(1., static_cast<double>(n));
47064706
auto [xx, yy] = meshgrid(x, y);
4707-
return this->quiver3(xx, yy, z, u, v, w, m, scale, line_spec);
4707+
return this->quiver3(xx, yy, z, u, v, w, c, scale, line_spec);
47084708
}
47094709

4710-
/// Quiver 3d - Automatic x and y - 2d vectors no magnitude
4710+
/// Quiver 3d - Automatic x and y - 2d vectors no color mapping
47114711
vectors_handle axes_type::quiver3(const std::vector<std::vector<double>> &z,
47124712
const std::vector<std::vector<double>> &u,
47134713
const std::vector<std::vector<double>> &v,
@@ -4718,7 +4718,7 @@ namespace matplot {
47184718
scale, line_spec);
47194719
}
47204720

4721-
/// Quiver 3d - no magnitude
4721+
/// Quiver 3d - no color mapping
47224722
vectors_handle axes_type::quiver3(
47234723
const std::vector<double> &x, const std::vector<double> &y,
47244724
const std::vector<double> &z, const std::vector<double> &u,

source/matplot/core/axes_type.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,27 +1409,27 @@ namespace matplot {
14091409
const std::vector<double> &y,
14101410
const std::vector<double> &u,
14111411
const std::vector<double> &v,
1412-
const std::vector<double> &m, double scale = 1.0,
1412+
const std::vector<double> &c, double scale = 1.0,
14131413
std::string_view line_spec = "");
14141414

14151415
/// Quiver - 2d x,y,u,v
14161416
vectors_handle quiver(const std::vector<std::vector<double>> &x,
14171417
const std::vector<std::vector<double>> &y,
14181418
const std::vector<std::vector<double>> &u,
14191419
const std::vector<std::vector<double>> &v,
1420-
const std::vector<std::vector<double>> &m,
1420+
const std::vector<std::vector<double>> &c,
14211421
double scale = 1.0,
14221422
std::string_view line_spec = "");
14231423

1424-
/// Quiver - 2d x,y,u,v with no magnitude
1424+
/// Quiver - 2d x,y,u,v with no color mapping
14251425
vectors_handle quiver(const std::vector<std::vector<double>> &x,
14261426
const std::vector<std::vector<double>> &y,
14271427
const std::vector<std::vector<double>> &u,
14281428
const std::vector<std::vector<double>> &v,
14291429
double scale = 1.0,
14301430
std::string_view line_spec = "");
14311431

1432-
/// Quiver - x,y,u,v with no magnitude
1432+
/// Quiver - x,y,u,v with no color mapping
14331433
vectors_handle quiver(const std::vector<double> &x,
14341434
const std::vector<double> &y,
14351435
const std::vector<double> &u,
@@ -1441,7 +1441,7 @@ namespace matplot {
14411441
quiver3(const std::vector<double> &x, const std::vector<double> &y,
14421442
const std::vector<double> &z, const std::vector<double> &u,
14431443
const std::vector<double> &v, const std::vector<double> &w,
1444-
const std::vector<double> &m, double scale = 1.0,
1444+
const std::vector<double> &c, double scale = 1.0,
14451445
std::string_view line_spec = "");
14461446

14471447
/// Quiver 3d - 2d vectors
@@ -1451,11 +1451,11 @@ namespace matplot {
14511451
const std::vector<std::vector<double>> &u,
14521452
const std::vector<std::vector<double>> &v,
14531453
const std::vector<std::vector<double>> &w,
1454-
const std::vector<std::vector<double>> &m,
1454+
const std::vector<std::vector<double>> &c,
14551455
double scale = 1.0,
14561456
std::string_view line_spec = "");
14571457

1458-
/// Quiver 3d - 2d vectors no magnitude
1458+
/// Quiver 3d - 2d vectors no color mapping
14591459
vectors_handle quiver3(const std::vector<std::vector<double>> &x,
14601460
const std::vector<std::vector<double>> &y,
14611461
const std::vector<std::vector<double>> &z,
@@ -1470,19 +1470,19 @@ namespace matplot {
14701470
const std::vector<std::vector<double>> &u,
14711471
const std::vector<std::vector<double>> &v,
14721472
const std::vector<std::vector<double>> &w,
1473-
const std::vector<std::vector<double>> &m,
1473+
const std::vector<std::vector<double>> &c,
14741474
double scale = 1.0,
14751475
std::string_view line_spec = "");
14761476

1477-
/// Quiver 3d - Automatic x and y - 2d vectors no magnitude
1477+
/// Quiver 3d - Automatic x and y - 2d vectors no color mapping
14781478
vectors_handle quiver3(const std::vector<std::vector<double>> &z,
14791479
const std::vector<std::vector<double>> &u,
14801480
const std::vector<std::vector<double>> &v,
14811481
const std::vector<std::vector<double>> &w,
14821482
double scale = 1.0,
14831483
std::string_view line_spec = "");
14841484

1485-
/// Quiver 3d - no magnitude
1485+
/// Quiver 3d - no color mapping
14861486
vectors_handle
14871487
quiver3(const std::vector<double> &x, const std::vector<double> &y,
14881488
const std::vector<double> &z, const std::vector<double> &u,

0 commit comments

Comments
 (0)