Skip to content

Commit d97af3a

Browse files
committed
Add gnuplot annotation hook and LaTeX-like arrow/equation 3-line example
1 parent d0d6d65 commit d97af3a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

examples/three_line_ieee_example.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ int main(int argc, char** argv) {
3535
ax.legend = true;
3636
ax.grid = true;
3737
ax.ylog = true;
38+
ax.gnuplot_commands = {
39+
"set label 1 'e_p(t)=e_0 e^{-{/Symbol l} t}' at 18,4.0 font 'Times,8'",
40+
"set arrow 1 from 34,3.6 to 58,1.9 lw 1.0 lc rgb '#000000'"};
3841
fig.axes(0).set(ax);
3942

4043
std::vector<double> t;

include/gnuplotpp/plot.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ struct AxesSpec {
7070

7171
bool xlog = false;
7272
bool ylog = false;
73+
74+
// Optional raw gnuplot commands for advanced annotations (arrows/labels/etc).
75+
std::vector<std::string> gnuplot_commands;
7376
};
7477

7578
/** @brief Supported series drawing types. */

src/gnuplot_backend.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ void emit_plot_body(std::ostream& os,
231231
os << "set yrange [" << axis_spec.ymin << ":" << axis_spec.ymax << "]\n";
232232
}
233233

234+
for (const auto& cmd : axis_spec.gnuplot_commands) {
235+
os << cmd << "\n";
236+
}
237+
234238
if (axis.series().empty()) {
235239
os << "plot 1/0 notitle\n";
236240
continue;

0 commit comments

Comments
 (0)