Skip to content

Commit

Permalink
allow mixed use of in-key plot titles and manually placed titles
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeam committed Sep 13, 2017
1 parent 81e0d95 commit c388662
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2017-09-13 Ethan A Merritt <[email protected]>

* src/graphics.c src/graph3d.c: The "title at {beg|end|<position>}"
options were originally intended as an alternative to the normal key,
so preservation of the key layout was not a concern. This patch allows
you to mix custom-placed titles with in-key titles in the same plot.
Bug #1967

2017-09-11 Ethan A Merritt <[email protected]>

* src/graphics.c src/graphics.h src/set.c src/tables.c src/tables.h
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Changes not in 5.2
* CHANGE special case optimization of nonlinear code to speed up logscale
* CHANGE windows terminal can print using Direct2D
* CHANGE windows Direct2D backend supports pattern fill
* FIX allow mixed use of in-key plot titles and manually placed titles

New features, changes and fixes in gnuplot version 5.2
======================================================
Expand Down
18 changes: 9 additions & 9 deletions src/graph3d.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static char *RCSid() { return RCSid("$Id: graph3d.c,v 1.370 2017-08-17 18:05:23 sfeam Exp $"); }
static char *RCSid() { return RCSid("$Id: graph3d.c,v 1.371 2017-09-13 22:59:29 sfeam Exp $"); }
#endif

/* GNUPLOT - graph3d.c */
Expand Down Expand Up @@ -997,9 +997,9 @@ do_3dplot(

/* User-specified key locations can use the 2D code */
if (this_plot->title_position) {
xl_prev = xl;
yl_prev = yl;
if (this_plot->title_position->scalex != character) {
xl_prev = xl;
yl_prev = yl;
map3d_position(this_plot->title_position, &xl, &yl, "key sample");
xl -= (key->just == GPKEY_LEFT) ? key_text_left : key_text_right;
} else {
Expand Down Expand Up @@ -1215,15 +1215,15 @@ do_3dplot(

} /* switch(plot-style) key sample */

/* move down one line in the key... */
if (lkey)
NEXT_KEY_LINE();

/* but not if the plot title was drawn somewhere else */
/* If the title went somewhere other than the key,
* restore the previous key position.
* Else move down one line in the key.
*/
if (this_plot->title_position) {
xl = xl_prev;
yl = yl_prev;
}
} else if (lkey)
NEXT_KEY_LINE();

/* Draw contours for previous surface */
if (draw_contour && this_plot->contours != NULL) {
Expand Down
8 changes: 5 additions & 3 deletions src/graphics.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static char *RCSid() { return RCSid("$Id: graphics.c,v 1.573 2017-09-12 15:16:53 sfeam Exp $"); }
static char *RCSid() { return RCSid("$Id: graphics.c,v 1.574 2017-09-13 22:59:29 sfeam Exp $"); }
#endif

/* GNUPLOT - graphics.c */
Expand Down Expand Up @@ -704,12 +704,14 @@ do_plot(struct curve_points *plots, int pcount)
ignore_enhanced(this_plot->title_no_enhanced);
/* don't write filename or function enhanced */
if (localkey && this_plot->title && !this_plot->title_is_suppressed) {
if (!this_plot->title_position) {
/* If title is "at {end|beg}" do not draw it in the key */
if (!this_plot->title_position
|| this_plot->title_position->scalex != character) {
key_count++;
if (key->invert)
yl = key->bounds.ybot + yl_ref + key_entry_height/2 - yl;
do_key_sample(this_plot, key, this_plot->title, xl, yl);
}
do_key_sample(this_plot, key, this_plot->title, xl, yl);
}
ignore_enhanced(FALSE);
}
Expand Down

0 comments on commit c388662

Please sign in to comment.