bugGNU Octave - Bugs: bug #38263, legend text color for gnuplot

 
 

bug #38263: legend text color for gnuplot

Submitter:  Ben Abbott <bpabbott>
Submitted:  Tue 05 Feb 2013 01:57:49 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  bpabbott
Originator Name:  Ben Abbott Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 17 May 2013 12:17:05 AM UTC, comment #3: 

Its been several months since the patch was applied.  I'm closing this one.

Ben Abbott <bpabbott>
Group Member
Wed 06 Feb 2013 03:07:40 PM UTC, comment #2: 
Ben Abbott <bpabbott>
Group Member
Tue 05 Feb 2013 04:09:23 PM UTC, comment #1: 

patch attached to bug 38265

Ben Abbott <bpabbott>
Group Member
Tue 05 Feb 2013 01:57:49 PM UTC, original submission:  

Matlab allows the text for the legend's entries to be modified by changing the color property of the legend's text objects.

plot (rand (3));
[hl, hc] = legend ({"first", "second", "third"})
[hl, hc] = legend ({"first", "second", "third"})
hl = -9.9382
hc =

  -14.280  -17.483  -15.525  -18.609  -16.223  -19.801
get (hc, "type")
ans =
{
  [1,1] = text
  [2,1] = line
  [3,1] = text
  [4,1] = line
  [5,1] = text
  [6,1] = line
}


Since there isn't a reliable way for Octave to know the extents of the text objects for the gnuplot toolkit, the Gnuplot "key" feature is used to render the legend.  Gnuplot does not allow the text color of the entries to be specified arbitrarily.  However, the current situation where the text is always black may be improved upon.

The color of all text objects may be modified using the Gnuplot syntax below.


set key textcolor "#RRGGBB";


This form is already supported by changing the "textcolor" property of the legend hggroup object.

Gnuplot also supports matching the color of the text labels to the graphic objects,


set key textcolor variable;


This feature may be included in Octave using a patch like below.


$ hg diff
diff --git a/scripts/plot/private/__go_draw_axes__.m b/scripts/plot/private/__go_draw_axes__.m
--- a/scripts/plot/private/__go_draw_axes__.m
+++ b/scripts/plot/private/__go_draw_axes__.m
@@ -1591,7 +1591,13 @@
       else
         fontspec = "";
       endif
-      colorspec = get_text_colorspec (hlgnd.textcolor, mono);
+      textcolors = cell2mat (get(findobj (hlgnd.children, "type", "text"), "color"));
+      textcolors = unique (textcolors, "rows");
+      if (rows (textcolors) > 1)
+        colorspec = "textcolor variable";
+      else
+        colorspec = get_text_colorspec (textcolors, mono);
+      endif
       fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s %s;\n",
                inout, pos, box, reverse, horzvert, fontspec, colorspec);
     else


The "set key textcolor variable" syntax may not be consistent across all versions of Gnuplot. This needs to be checked before committing.  If necessary the _gnuplot_has_feature_.m function may need to be modified as well.


Ben Abbott <bpabbott>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bpabbott (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-05-17 bpabbott StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2013-02-06 bpabbott StatusPatch Submitted Ready For Test
    2013-02-05 bpabbott StatusNone Patch Submitted
        Assigned toNone bpabbott

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code