bugGNU Octave - Bugs: bug #52842, Implement "none" as a...

 
 

bug #52842: Implement "none" as a standard option for graphics color properties

Submitter:  Rik <rik5>
Submitted:  Tue 09 Jan 2018 01:07:40 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 06 Feb 2019 07:34:13 PM UTC, comment #10: 

Remaining instances in graphics.in.h which might be useful to add "none" to are shown below.  Offhand, the only one that feels like it should be done soon is light objects.


AXES
3609:      color_property ambientlightcolor , color_values (1, 1, 1)

LIGHT
4724:      color_property color , color_values (1, 1, 1)

UIMENU
5351:      color_property foregroundcolor , color_values (0, 0, 0)

UICONTROL
5480:      color_property backgroundcolor , color_values (0.94, 0.94, 0.94)
5492:      color_property foregroundcolor , color_values (0, 0, 0)

UIBUTTONGROUP
5594:      color_property backgroundcolor , color_values (0.94, 0.94, 0.94)
5604:      color_property foregroundcolor , color_values (0, 0, 0)
5605:      color_property highlightcolor , color_values (1, 1, 1)
5613:      color_property shadowcolor , color_values (0.7, 0.7, 0.7)

UIPANEL
5687:      color_property backgroundcolor , color_values (0.94, 0.94, 0.94)
5696:      color_property foregroundcolor , color_values (0, 0, 0)
5697:      color_property highlightcolor , color_values (1, 1, 1)
5703:      color_property shadowcolor , color_values (0.7, 0.7, 0.7)

UITABLE
5790:      color_property foregroundcolor , color_values (0, 0, 0)



Rik <rik5>
Group administrator
Wed 06 Feb 2019 07:02:25 PM UTC, comment #9: 

There were a huge number of special cases involved aroung the grid and minorgrid, and we didn't have the "gridcolor" property set up to change "gridcolormode" to "manual" when you changed "gridcolor".  I sorted it all out and checked it in here (https://hg.savannah.gnu.org/hgweb/octave/rev/0780d3f4ecad).

As a side note, Octave actually performs better than Matlab now.  If you set the "minorgridcolor" property in Matlab to "none", it actually continues to draw the minor grid, but in the default color.

Rik <rik5>
Group administrator
Tue 05 Feb 2019 09:40:29 PM UTC, comment #8: 

@Rik: When a color property is set to "none", get_color_rgb () returns an empty matrix. I attached an update of your patch in which I took care of not rendering objects (grid, text, box ...) when their color is empty.

(file #46187)

Pantxo Diribarne <pantxo>
Group Member
Tue 05 Feb 2019 04:22:45 PM UTC, comment #7: 

@Pantxo: Feel free to add an updater to make the code more regular.  I think the existing code was more of a hack to get things to work, before we were more thoughtful about the code architecture.

Also, as you have guessed, the whole purpose of this feature request is to have more control over graphics objects so I can create complicated scenarios.  For example, to have just a horizontal baseline, I might do


clf;
hax = gca;
set (hax, 'xaxislocation', 'origin')
ylim ([-1 1])
set (hax, 'ycolor', 'none')


I'm not sure I agree with it, but for axes sub-objects like ylabel, setting the color to "none" makes the object disappear, but it is still including in positioning calculations.  Setting the string to the empty string, ylabel (''), also causes the object to disappear AND the axes are re-sized to account for the disappearance.

For text objects the behavior is different.  No color means the object isn't plotted.  I tested with this code


clf;
ht = text (0.5, 0.5, 'Hello World', 'FontSize', 16);
set (ht, 'backgroundcolor', 'm')
set (ht, 'edgecolor', 'k', 'linewidth', 3)
set (ht, 'color', 'none')


An empty string also causes the text object to disappear


clf;
ht = text (0.5, 0.5, 'Hello World', 'FontSize', 16);
set (ht, 'backgroundcolor', 'm')
set (ht, 'edgecolor', 'k', 'linewidth', 3)
set (ht, 'string', '')


Given that this is how text objects work, and a ylabel is just a text object, I would say we code up the axes behavior whichever way is most convenient.  If that means the object isn't drawn and the axes position is re-calculated that would be fine.

Rik <rik5>
Group administrator
Tue 05 Feb 2019 02:34:44 PM UTC, comment #6: 

@Rik: I tested in Matlab 2016a and indeed 'none' is equivalent to 'transparent'. This makes sense: if you want no ticks and no labels you'll use ("ytick", []) and won't define a ylabel string, on the other hand if you what the same figure but don't wan't text strings to appear, then you'll just have to make text strings transparent using "none".

It is also much easier to implement since you just have to implement "color" = "none" in ft_text_renderer. I will try to provide you with a partial cset for this.

Also, I see that your approach has been to set labels "visible" property to "off", at rendering time. Is there any reason to not add an updater (axes::properties::update_x(yz)color) that will change the corresponding label "color" property? This would be consistent with how we usually proceed (e.g. axes::properties::update_fontsize), an avoid changing the property  each time the figure is rendered.

Pantxo Diribarne <pantxo>
Group Member
Tue 05 Feb 2019 10:24:28 AM UTC, comment #5: 


> If an object isn't displayed, it shouldn't affect other objects which are displayed.

(Maybe I don't understand comment #4 very well.)
One can argue that "none" is just another color and that not displaying s/th having color "none" is just a side effect. IOW, it is drawn but w/o color.
Is that what you mean, Rik?

I think of a scenarios e.g., where one can interactively change plots and repositioning of axes etc. happens if labels are displayed or not (the latter for e.g., uncluttering a plot). That might be unexpected and even unwanted.

Philip Nienhuis <philipnienhuis>
Group Member
Tue 05 Feb 2019 04:47:05 AM UTC, comment #4: 

Just to be certain, I checked in Matlab and it does re-position the axes, even when "color" is "none", but it doesn't display the ylabel.  I think that is a bug on their part.  If an object isn't displayed, it shouldn't affect other objects which are displayed.

Rik <rik5>
Group administrator
Tue 05 Feb 2019 12:03:29 AM UTC, comment #3: 

I tested with Matlab and "color" none means the text object itself is not displayed (no background even if "backgroundcolor" is set).  It's basically like toggling the "visible" property.  Hence, the axes object should ignore the ylabel if its color is "none" when figuring position.

Rik <rik5>
Group administrator
Mon 04 Feb 2019 11:32:17 PM UTC, comment #2: 

In your example, what is the intended behavior? Should the box be drawn even though the text is not?

Also, how should the axes position be handled, i.e. in the folowing example:


clf;
hax = axes ("fontsize", 40, "ylabel", "YLABEL", "ycolor", "none");


Should the axes be shrunk, as if I had used (..."ycolor", "w"), or not, as if I had used (..., "ylabel, "", "ytick", [], "ycolor", "w")?

Pantxo Diribarne <pantxo>
Group Member
Mon 04 Feb 2019 08:08:46 PM UTC, comment #1: 

@Pantxo: Could you take a look at the attached cset?  It implements "none" as a color for text and axes objects.  It mostly works, except that I'm getting warnings from ft_text_renderer.



warning: ft_text_renderer::set_color: invalid color
warning: called from
    text at line 170 column 10


I have been using this to test with:


clf;
hax = gca;
ht = text (0.5, 0.5, 'Hello World', 'color', 'none', 'backgroundcolor', 'm');




(file #46179)

Rik <rik5>
Group administrator
Tue 09 Jan 2018 01:07:40 AM UTC, original submission:  

It seems that most (all?) Matlab graphics objects which support a color property support the value of "none".  This is in addition to either a string like "magenta" or a 1x3 RGB specification.

The advantage of having no color is it allows for very selective disabling of pieces of the plot.  For example, How do you create a baseline along the X-axis and NO Y-axis?  You can't use the "visible" property of the axes object because that will disable everything.  If "none" was an option then you could do


set (gca, "Ycolor", "none")


and get what you want quite simply.

This is really just extending a feature that has already existed for certain graphic objects, to all graphic objects.  For example, the a surface primitive object has EdgeColor and FaceColor properties.  If I want a mesh-style graph then I set EdgeColor to some value and FaceColor to "none".  Conversely if I just want a surface then I set FaceColor to some value and EdgeColor to "none".

This should be relatively simple.  libinterp/corefcn/graphics.in.h needs to be amended to have "none" be a valid radio_property.  See the code for color property of the figure object:


color_property color , color_property (color_values (1, 1, 1), radio_values ("none"))


Second, the toolkits that actually draw things need to be updated.  This is libinterp/corefcn/gl-render.cc for FLTK and Qt toolkits, or scripts/plot/util/private/__gnuplot_draw_axes__.m for gnuplot.  I care more about the OpenGl toolkits though.

Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #46187:  52842.v2.cset added by pantxo (10KiB - application/octet-stream)
file #46179:  52842.v1.cset added by rik5 (4KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by rik5 (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-05 pantxo Attached File- Added 52842.v2.cset, #46187
    2019-02-04 rik5 Attached File- Added 52842.v1.cset, #46179
        Carbon-Copy- Added pantxo

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code