gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/plot.cpp
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2013年02月05日 11:27:47 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2013年02月05日 11:27:47 +0100
commitd8eb30e6de3d8cab29bd868c24d226ff3d26a088 (patch)
tree51a9c6b613c9c1d698f9e4f82caaaf4dedb5675e /agg-plot/plot.cpp
parentdac5106531534f5dbc7e223a30acbdc7a8c686ca (diff)
downloadgsl-shell-d8eb30e6de3d8cab29bd868c24d226ff3d26a088.tar.gz
Improves plot limits calculation when multi labels are used
Diffstat (limited to 'agg-plot/plot.cpp')
-rw-r--r--agg-plot/plot.cpp 11
1 files changed, 11 insertions, 0 deletions
diff --git a/agg-plot/plot.cpp b/agg-plot/plot.cpp
index 0882d458..04ab38d4 100644
--- a/agg-plot/plot.cpp
+++ b/agg-plot/plot.cpp
@@ -145,6 +145,17 @@ void plot::compute_user_trans()
r = m_rect.is_defined() ? m_rect.rect() : agg::rect_base<double>(0.0, 0.0, 1.0, 1.0);
}
+ if (m_xaxis_hol)
+ {
+ for (unsigned k = 0; k < m_xaxis_hol->size(); k++)
+ {
+ factor_labels* f = m_xaxis_hol->at(k);
+ double x1 = f->mark(0), x2 = f->mark(f->labels_number());
+ if (k == 0 || x1 < r.x1) r.x1 = x1;
+ if (k == 0 || x2 > r.x2) r.x2 = x2;
+ }
+ }
+
double dx = r.x2 - r.x1, dy = r.y2 - r.y1;
double fx = (dx == 0 ? 1.0 : 1/dx), fy = (dy == 0 ? 1.0 : 1/dy);
this->m_trans = agg::trans_affine(fx, 0.0, 0.0, fy, -r.x1 * fx, -r.y1 * fy);
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月17日 10:12:54 +0000

AltStyle によって変換されたページ (->オリジナル) /