s_xlegend = FALSE;
s_ylegend = FALSE;
s_textsize = FALSE;
+ s_xmin = FALSE;
+ s_xmax = FALSE;
+ s_ymin = FALSE;
+ s_ymax = FALSE;
clr_axis = C_LTGRAY; // set fixed colors
clr_title = C_RED;
double symheight = charheight * 0.3; // size of symbol in NDC
double symwidth = symheight;
- const EZPlotCurve& firstCurve = *m_vecCurves[0];
+ if (m_vecCurves.size() < 1)
+ return; // can't plot if there are no curves to plot
- double xmin = firstCurve.x[0]; // extent of curves in world coord
- double xmax = xmin;
- double ymin = firstCurve.y[0];
- double ymax = ymin;
+ // find a curve with at least one point to get base point
+ double xmin, xmax, ymin, ymax; // extent of curves in world coord
+ bool found = false;
- unsigned int iCurve;
- for (iCurve = 0; iCurve < m_vecCurves.size(); iCurve++) {
+ for (unsigned int iCurve = 0; iCurve < m_vecCurves.size(); iCurve++) {
+ const EZPlotCurve* const pCurve = m_vecCurves [iCurve];
+ if (pCurve->m_iPointCount > 0) {
+ xmin = pCurve->x[0];
+ xmax = xmin;
+ ymin = pCurve->y[0];
+ ymax = ymin;
+ found = true;
+ break;
+ }
+ }
+ if (! found)
+ return; // curve(s) are empty, so no plotting
+
+ for (unsigned int iCurve = 0; iCurve < m_vecCurves.size(); iCurve++) {
const EZPlotCurve* const pCurve = m_vecCurves [iCurve];
for (int ip = 0; ip < pCurve->m_iPointCount; ip++) {
if (! axis_scale (xmin, xmax, o_xmajortick - 1, &xgw_min, &xgw_max, &x_nint) || ! axis_scale (ymin, ymax, o_ymajortick - 1, &ygw_min, &ygw_max, &y_nint))
return;
+
// check if user set x-axis extents
if (s_xmin == TRUE) {
xgw_min = v_xmin;
int max_leg = 0; // longest legend in characters
int num_leg = 0; // number of legend titles
- for (iCurve = 0; iCurve < m_vecCurves.size(); iCurve++) {
+ for (unsigned int iCurve = 0; iCurve < m_vecCurves.size(); iCurve++) {
const std::string* pstrLegend = getLegend (iCurve);
if (pstrLegend && pstrLegend->length() > 0) {
int iLegend = 0; // current legend position
- for (iCurve = 0; iCurve < m_vecCurves.size(); iCurve++) {
+ for (unsigned int iCurve = 0; iCurve < m_vecCurves.size(); iCurve++) {
const std::string* pstrLegend = getLegend (iCurve);
if (! pstrLegend || pstrLegend->length() == 0)
continue;
- for (iCurve = 0; iCurve < m_vecCurves.size(); iCurve++) {
+ for (unsigned int iCurve = 0; iCurve < m_vecCurves.size(); iCurve++) {
const EZPlotCurve* const pCurve = m_vecCurves [iCurve];
-
m_pSGP->setColor (getColor (iCurve));
-
int iSym = getSymbol (iCurve);
-
int iLS = getLinestyle (iCurve);
-
-
if (iLS != SGP::LS_NOLINE) {
m_pSGP->setLineStyle (iLS);
double x1 = convertWorldToNDC_X (pCurve->x[0]);
m_pSGP->setColor (clr_axis);
m_pSGP->moveAbs (x, xaxispos);
m_pSGP->lineAbs (x, xaxispos + xticklen);
- if (i != x_nint)
+ if (i != x_nint) {
for (j = 1; j <= o_xminortick; j++) {
x2 = x + minorinc * j;
m_pSGP->moveAbs (x2, xaxispos);
m_pSGP->lineAbs (x2, xaxispos + TICKRATIO * xticklen);
}
- axis_near = FALSE;
- if (xaxispos + xtl_ofs > ya_min && o_yaxis != NOAXIS) {
- double xw = xgw_min + i * xw_tickinc;
- double x = convertWorldToNDC_X (xw);
- double d = x - yaxispos;
- if (o_yticks == RIGHT && d >= 0 && d < 0.9 * xn_tickinc)
- axis_near = TRUE;
- if (o_yticks == LEFT && d <= 0 && d > -0.9 * xn_tickinc)
- axis_near = TRUE;
- }
+ }
+ axis_near = FALSE;
+ if (xaxispos + xtl_ofs > ya_min && o_yaxis != NOAXIS) {
+ double xw = xgw_min + i * xw_tickinc;
+ double x = convertWorldToNDC_X (xw);
+ double d = x - yaxispos;
+ if (o_yticks == RIGHT && d >= 0 && d < 0.9 * xn_tickinc)
+ axis_near = TRUE;
+ if (o_yticks == LEFT && d <= 0 && d > -0.9 * xn_tickinc)
+ axis_near = TRUE;
+ }
- if (o_xtlabel == TRUE && axis_near == FALSE) {
- snprintf (str, sizeof(str), x_numfmt, xgw_min + xw_tickinc * i);
- numstr = str_skip_head (str, " ");
- double xExtent, yExtent;
- m_pSGP->getTextExtent (numstr, &xExtent, &yExtent);
- m_pSGP->moveAbs (x - xExtent/2, xaxispos + xtl_ofs);
- m_pSGP->setTextColor (clr_number, -1);
- m_pSGP->drawText (numstr);
- }
+ if (o_xtlabel == TRUE && axis_near == FALSE) {
+ snprintf (str, sizeof(str), x_numfmt, xgw_min + xw_tickinc * i);
+ numstr = str_skip_head (str, " ");
+ double xExtent, yExtent;
+ m_pSGP->getTextExtent (numstr, &xExtent, &yExtent);
+ m_pSGP->moveAbs (x - xExtent/2, xaxispos + xtl_ofs);
+ m_pSGP->setTextColor (clr_number, -1);
+ m_pSGP->drawText (numstr);
+ }
}
} // X - Axis
-
-
+
+
/*--------*/
/* y-axis */
/*--------*/
-
+
if (o_yaxis == LINEAR) {
-
+
m_pSGP->setColor (clr_axis);
if (o_tag && !o_grid && !o_box && s_ycross) {
m_pSGP->moveAbs (yaxispos - charwidth, ya_min);
m_pSGP->setColor (clr_axis);
m_pSGP->moveAbs (yaxispos, y);
m_pSGP->lineAbs (yaxispos + yticklen, y);
- if (i != y_nint)
+ if (i != y_nint) {
for (j = 1; j <= o_yminortick; j++) {
y2 = y + minorinc * j;
m_pSGP->moveAbs (yaxispos, y2);
m_pSGP->lineAbs (yaxispos + TICKRATIO * yticklen, y2);
}
- axis_near = FALSE;
- if (yaxispos + ytl_ofs > xa_min && o_xaxis != NOAXIS) {
- double yw = ygw_min + i * yw_tickinc;
- double y = convertWorldToNDC_Y (yw);
- double d = y - xaxispos;
- if (o_xticks == ABOVE && d >= 0 && d < 0.9 * yn_tickinc)
- axis_near = TRUE;
- if (o_xticks == BELOW && d <= 0 && d > -0.9 * yn_tickinc)
- axis_near = TRUE;
- }
- if (o_ytlabel == TRUE && axis_near == FALSE) {
- snprintf (str, sizeof(str), y_numfmt, ygw_min + yw_tickinc * i);
- double xExtent, yExtent;
- m_pSGP->getTextExtent (str, &xExtent, &yExtent);
- if (o_yticks == LEFT)
- m_pSGP->moveAbs (yaxispos - 1.5 * charwidth - xExtent, y + 0.5 * yExtent);
- else
- m_pSGP->moveAbs (yaxispos + 1.5 * charwidth, y + 0.5 * yExtent);
- m_pSGP->setTextColor (clr_number, -1);
- m_pSGP->drawText (str);
- }
+ }
+ axis_near = FALSE;
+ if (yaxispos + ytl_ofs > xa_min && o_xaxis != NOAXIS) {
+ double yw = ygw_min + i * yw_tickinc;
+ double y = convertWorldToNDC_Y (yw);
+ double d = y - xaxispos;
+ if (o_xticks == ABOVE && d >= 0 && d < 0.9 * yn_tickinc)
+ axis_near = TRUE;
+ if (o_xticks == BELOW && d <= 0 && d > -0.9 * yn_tickinc)
+ axis_near = TRUE;
+ }
+ if (o_ytlabel == TRUE && axis_near == FALSE) {
+ snprintf (str, sizeof(str), y_numfmt, ygw_min + yw_tickinc * i);
+ double xExtent, yExtent;
+ m_pSGP->getTextExtent (str, &xExtent, &yExtent);
+ if (o_yticks == LEFT)
+ m_pSGP->moveAbs (yaxispos - 1.5 * charwidth - xExtent, y + 0.5 * yExtent);
+ else
+ m_pSGP->moveAbs (yaxispos + 1.5 * charwidth, y + 0.5 * yExtent);
+ m_pSGP->setTextColor (clr_number, -1);
+ m_pSGP->drawText (str);
+ }
}
} // Y - Axis
}