"fc palette frac" does not always work for objects

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

"fc palette frac" does not always work for objects

Juhász Péter
Dear gnuplot developers,

consider the following commands:

set obj 1 rect from 1,1 to 2,2 fc palette frac 0.5
plot x

The documentation says that the fillcolor part of the set object command accepts a generic colorspec directive, which in turn should allow a "fc palette frac" declaration.
Given the default palette I'd expect the above commands to produce a red rectangle on the plot, however, it comes out black.

However, if I change the plot command to

plot x lc palette frac 0.1

The rectangle suddenly gets the expected color. I also get a color bar next to the plot.

All of this suggests that in the first example some of the palette-related data structures are not initialized correctly, while in the second example they are, only because the palette is used with the function plot as well, and that plot triggers the necessary initialization sequence.

Peter Juhasz

------------------------------------------------------------------------------

_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: "fc palette frac" does not always work for objects

sfeam
On Saturday, 24 September 2016 12:51:56 PM Peter Juhasz wrote:

> Dear gnuplot developers,
>
> consider the following commands:
>
> set obj 1 rect from 1,1 to 2,2 fc palette frac 0.5
> plot x
>
> The documentation says that the fillcolor part of the set object command
> accepts a generic colorspec directive, which in turn should allow a "fc
> palette frac" declaration.
> Given the default palette I'd expect the above commands to produce a red
> rectangle on the plot, however, it comes out black.
>
> However, if I change the plot command to
>
> plot x lc palette frac 0.1
>
> The rectangle suddenly gets the expected color. I also get a color bar next
> to the plot.
>
> All of this suggests that in the first example some of the palette-related
> data structures are not initialized correctly, while in the second example
> they are, only because the palette is used with the function plot as well,
> and that plot triggers the necessary initialization sequence.
>
> Peter Juhasz

The program tries to figure out if a given plot requires the palette or not.
It looks through the plot style and various line and text properties, but it
does not look through the set of all defined objects.
A work-around, if you care, is to issue the command "set pm3d implicit".

I suppose the routine set_plot_with_palette() could be taught to check
for object colors also, but I wonder if the better question is why should
we not always initialize the palette even if no one is going to use it?

        Ethan


------------------------------------------------------------------------------
_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: "fc palette frac" does not always work for objects

Juhász Péter
On Sat, 2016-09-24 at 21:36 -0700, sfeam wrote:

> On Saturday, 24 September 2016 12:51:56 PM Peter Juhasz wrote:
> > Dear gnuplot developers,
> >
> > consider the following commands:
> >
> > set obj 1 rect from 1,1 to 2,2 fc palette frac 0.5
> > plot x
> >
> > The documentation says that the fillcolor part of the set object command
> > accepts a generic colorspec directive, which in turn should allow a "fc
> > palette frac" declaration.
> > Given the default palette I'd expect the above commands to produce a red
> > rectangle on the plot, however, it comes out black.
> >
> > However, if I change the plot command to
> >
> > plot x lc palette frac 0.1
> >
> > The rectangle suddenly gets the expected color. I also get a color bar next
> > to the plot.
> >
> > All of this suggests that in the first example some of the palette-related
> > data structures are not initialized correctly, while in the second example
> > they are, only because the palette is used with the function plot as well,
> > and that plot triggers the necessary initialization sequence.
> >
> > Peter Juhasz
>
> The program tries to figure out if a given plot requires the palette or not.
> It looks through the plot style and various line and text properties, but it
> does not look through the set of all defined objects.
> A work-around, if you care, is to issue the command "set pm3d implicit".
>
> I suppose the routine set_plot_with_palette() could be taught to check
> for object colors also, but I wonder if the better question is why should
> we not always initialize the palette even if no one is going to use it?
>

Yes, that could work. This would also automatically alleviate the
question of any other plot element we might have forgot that potentially
needs the palette but doesn't trigger it on its own.

I wonder, though, if there are any careless assumptions about the
palette in the code, for example "palette is initialized => draw the
colorbox", or in other words, initializing it all the time might expose
some unwanted side effects.  

> Ethan
>

Peter


------------------------------------------------------------------------------
_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: "fc palette frac" does not always work for objects

Petr Mikulik
>> I suppose the routine set_plot_with_palette() could be taught to check
>> for object colors also, but I wonder if the better question is why should
>> we not always initialize the palette even if no one is going to use it?
>
> Yes, that could work. This would also automatically alleviate the
> question of any other plot element we might have forgot that potentially
> needs the palette but doesn't trigger it on its own.
>
> I wonder, though, if there are any careless assumptions about the
> palette in the code, for example "palette is initialized => draw the
> colorbox", or in other words, initializing it all the time might expose
> some unwanted side effects.

There is some overhead with the palette code in terminals - they need more
init data (sending the palette, allocate more colours, write larger postscript
header, ...), as well as switching on the colorbox. Thus searching all objects
for their requirements is a prefered way.

---
PM


------------------------------------------------------------------------------
_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: "fc palette frac" does not always work for objects

sfeam
On Monday, 26 September 2016 10:04:26 AM Petr Mikulik wrote:

> >> I suppose the routine set_plot_with_palette() could be taught to check
> >> for object colors also, but I wonder if the better question is why should
> >> we not always initialize the palette even if no one is going to use it?
> >
> > Yes, that could work. This would also automatically alleviate the
> > question of any other plot element we might have forgot that potentially
> > needs the palette but doesn't trigger it on its own.
> >
> > I wonder, though, if there are any careless assumptions about the
> > palette in the code, for example "palette is initialized => draw the
> > colorbox", or in other words, initializing it all the time might expose
> > some unwanted side effects.
>
> There is some overhead with the palette code in terminals - they need more
> init data (sending the palette, allocate more colours, write larger postscript
> header, ...), as well as switching on the colorbox. Thus searching all objects
> for their requirements is a prefered way.

OK.
Can you think of any additional cases where the current checks in
set_plot_with_palette() fail to notice that a palette will be referenced?

        Ethan


------------------------------------------------------------------------------
_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta