Skip to content

closes #1893 #1900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/plotting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ namespace lib
char *i;
//special cases, since plplot gives approximate zero values, not strict zeros.
bool logWithPlainNumbers=false;
DFloat range=ptr->End-ptr->Start;
DDouble range=ptr->End-ptr->Start;
if (ptr->isLog) {
range=log10(ptr->End)-log10(ptr->Start);
if (range < 8) {
Expand Down Expand Up @@ -1577,7 +1577,7 @@ namespace lib
// 10^1->N (positive logs) give zero precision (integer numbers)
// < 1 numbers precision will be the abs of negative magnitude
int prec = 0;
int mag = log10(ptr->Start);
int mag = log10(float(ptr->Start)); // float() see #1887
if (mag < 0) prec = -mag;
snprintf(label, length, "%.*f", prec, pow(10, value));
return;
Expand Down Expand Up @@ -1683,7 +1683,7 @@ namespace lib
else if (what.substr(0, 6) == "MINUTE") convcode = 5;
else if (what.substr(0, 6) == "SECOND") convcode = 6;
else if (what.substr(0, 4) == "TIME") {
DFloat range=ptr->End-ptr->Start;
DDouble range=ptr->End-ptr->Start;
if (range >= 366) convcode = 1;
else if (range >= 32) convcode = 2;
else if (range >= 1.1) convcode = 3;
Expand Down Expand Up @@ -3684,7 +3684,7 @@ void SelfNormLonLat(DDoubleGDL *lonlat) {


gdlGetDesiredAxisTickGet(e, axisId, TickInterval, Start, End, Log);
if (Start == End) return;
if (Log && (Start <= 0 || End <= 0)) return; //important protection
bool doplot = ((AxisStyle & 4) != 4);
Expand Down Expand Up @@ -3854,6 +3854,8 @@ void SelfNormLonLat(DDoubleGDL *lonlat) {
tickdata.e = e;
tickdata.isLog = Log;
tickdata.Start = (Start>End)?End:Start;
//protect against (plplot) bug #1893
if (TickInterval + tickdata.Start == tickdata.Start) return; //the best we can do?
tickdata.End = (Start>End)?Start:End;
tickdata.nchars = 0;
tickdata.TickFormat = NULL;
Expand Down Expand Up @@ -3912,7 +3914,8 @@ void SelfNormLonLat(DDoubleGDL *lonlat) {
for (auto i = 0; i < tickdata.nTickUnits; ++i) //loop on TICKUNITS axis
{
if (i > 0 || TickInterval == 0) TickInterval = gdlComputeAxisTickInterval(e, axisId, Start, End, Log, i/*, (AxisStyle & 1) == 0*/);

//protect against (plplot) bug #1893
if (TickInterval+tickdata.Start == tickdata.Start) continue;
tickdata.nchars = 0; //set nchars to 0, at the end nchars will be the maximum size.
if (i == 1) tickOpt = (TickLayout == 2) ? tickLayout2 : additionalAxesTickOpt; //change style of ticks for supplemental axes
defineLabeling(a, axisId, gdlNoLabelTickFunc, &tickdata); //prevent plplot to write labels (but writes something, so that label positions are reported in getLabelingValues())
Expand Down
4 changes: 2 additions & 2 deletions src/plotting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ struct GDL_TICKDATA {
SizeT nTickUnits;
DStringGDL* TickUnits;
SizeT counter;
DFloat Start; //used where the span of values in axis matters. //FLOATS as IDL rounds range on floats. Probably uses only floats for graphics. I would do the same.
DFloat End; //used where the spand of values in axis matters.
DDouble Start; //used where the span of values in axis matters.
DDouble End; //used where the spand of values in axis matters.
double nchars; //length of string *returned* after formatting. Can be non-integer.
int tickOptionCode;
int tickLayoutCode;
Expand Down
Loading