Skip to content

Commit

Permalink
Minor update (more code cleanup).
Browse files Browse the repository at this point in the history
  • Loading branch information
pazmivaniye committed Jun 16, 2024
1 parent 3e3b323 commit b3f9334
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 34 deletions.
30 changes: 8 additions & 22 deletions axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static void compile(const std::string& path, const std::string& src, bool
static const std::string src0 =
"\\IfFileExists{standalone.cls}{}{\\errmessage{The \"standalone\" package i"
"s required.}}" + endl +
"\\documentclass"/*[varwidth]*/"{standalone}" + endl +
"\\documentclass{standalone}" + endl +
"\\usepackage{xstring}" + endl +
"\\makeatletter" + endl +
"\\@ifclasslater{standalone}{2018/03/26}{}{\\usepackage{luatex85}}" + endl +
Expand Down Expand Up @@ -511,12 +511,12 @@ void pgfplotter::Axis::squeeze()
ySqueeze = true;
}

void pgfplotter::Axis::squeeze_x()
void pgfplotter::Axis::squeezeX()
{
xSqueeze = true;
}

void pgfplotter::Axis::squeeze_y()
void pgfplotter::Axis::squeezeY()
{
ySqueeze = true;
}
Expand Down Expand Up @@ -686,7 +686,7 @@ void pgfplotter::Axis::setView(double az, double el)
_viewAngles = {az, el};
}

void pgfplotter::Axis::opacity(double n)
void pgfplotter::Axis::setSurfOpacity(double n)
{
_opacity = n;
}
Expand All @@ -696,8 +696,8 @@ void pgfplotter::Axis::noSep()
_noSep = true;
}

void pgfplotter::Axis::xTicks(const std::vector<double>& locations, const std::vector<
std::string>& labels, bool rotate)
void pgfplotter::Axis::setXTicks(const std::vector<double>& locations, const
std::vector<std::string>& labels, bool rotate)
{
_xTicks = locations;
_xTickLabels = labels;
Expand Down Expand Up @@ -867,7 +867,6 @@ std::string pgfplotter::Axis::plot_src(const std::string& path, int subplot) con

const double tempYMin = yMinSet ? yMin : yMinData;
const double tempYMax = yMaxSet ? yMax : yMaxData;
//const double yRange = tempYMax - tempYMin;
if(yMinSet || ySqueeze)
{
src += ", ymin = " + ToString(tempYMin);
Expand All @@ -876,11 +875,6 @@ std::string pgfplotter::Axis::plot_src(const std::string& path, int subplot) con
{
src += ", ymax = " + ToString(tempYMax);
}
/*if((yMinSet && yMaxSet) || ySqueeze) // Disables Lua backend if mesh plot
{
src += ", restrict y to domain = " + ToString(tempYMin - 10.0*yRange) +
":" + ToString(tempYMax + 10.0*yRange);
}*/

// Z/meta max/min don't seem to affect contour placement in contour plots.
if(zMinSet)
Expand All @@ -899,11 +893,6 @@ std::string pgfplotter::Axis::plot_src(const std::string& path, int subplot) con
}
src += ", point meta max = " + ToString(zMax);
}
/*if(zMinSet && zMaxSet)
{
src += ", restrict z to domain = " + ToString(zMin) + ":" + ToString(
zMax);//TEMP
}*/

if(!_xLabel.empty())
{
Expand Down Expand Up @@ -1206,15 +1195,12 @@ std::string pgfplotter::Axis::plot_src(const std::string& path, int subplot) con
}
}

if(legendPos)// && names.size() == data.size())
if(legendPos)
{
src += "\\legend{";
for(const auto& n : names)
{
// if(!n.empty())
{
src += n + ", ";
}
src += n + ", ";
}
src += "}" + endl;
}
Expand Down
24 changes: 12 additions & 12 deletions pgfplotter
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ namespace pgfplotter
std::vector<double> lineWidths;
std::vector<double> opacities;

std::array<double, 2> _viewAngles = {0.0, 90.0};
std::array<double, 2> _viewAngles = {0., 90.};

double _opacity = 1.0; // Should be per-surface (like `surfaceX`, etc.).
double _opacity = 1.; // Should be per-surface (like `surfaceX`, etc.).

unsigned int legendPos = 0;

Expand All @@ -140,8 +140,8 @@ namespace pgfplotter
bool axisEqual = false;
bool axisEqualImage = false;

double relWidth = 1.0;
double relHeight = 1.0;
double relWidth = 1.;
double relHeight = 1.;

int xPrecision = -1;
int yPrecision = -1;
Expand All @@ -157,11 +157,11 @@ namespace pgfplotter

bool _showColorbar = false;

double xSpacing = 0.0;
double ySpacing = 0.0;
double zSpacing = 0.0;
double xSpacing = 0.;
double ySpacing = 0.;
double zSpacing = 0.;

double xOffset = 0.0;
double xOffset = 0.;

bool _noSep = false;

Expand Down Expand Up @@ -211,8 +211,8 @@ namespace pgfplotter

void legend(unsigned int location = Northeast);
void squeeze();
void squeeze_x();
void squeeze_y();
void squeezeX();
void squeezeY();
void setXMin(double x);
void setXMax(double x);
void setYMin(double y);
Expand Down Expand Up @@ -242,9 +242,9 @@ namespace pgfplotter
void scale_z_spacing(double n);
void x_offset(double n);
void setView(double az, double el);
void opacity(double n);
void setSurfOpacity(double n);
void noSep();
void xTicks(const std::vector<double>& locations, const std::vector<
void setXTicks(const std::vector<double>& locations, const std::vector<
std::string>& labels = {}, bool rotate = false);
void bgBands(const std::vector<double>& transitions);
void bidirColormap();
Expand Down

0 comments on commit b3f9334

Please sign in to comment.