2d matrix plots 'with labels'

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

2d matrix plots 'with labels'

Dima Kogan
Hi.

I think the following is a bug? Maybe?

I'm using a bleeding edge build of gnuplot from

    https://github.com/gnuplot/gnuplot/commit/ca59a14e94df23008200f34cdb7ea8bc017ad946

Plotting a matrix of numbers as points with varying colors works ok:

    plot '-' matrix using 1:2:3 notitle with points pt 7 ps 2 palette
    1 2 3
    4 5 6
    e

I get 6 points in a grid, with different colors. I would expect that
plotting the same thing 'with labels' should work too, but with printed
text instead of points

    plot '-' matrix using 1:2:3 notitle with labels
    1 2 3
    4 5 6
    e

I get the grid of printed text, but each "point" is "6" and not "1",
"2", ...

Bug?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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
|  
Report Content as Inappropriate

Re: 2d matrix plots 'with labels'

Gnuplot - Dev mailing list
On Wednesday, 26 July 2017 14:49:07 Dima Kogan wrote:

> Hi.
>
> I think the following is a bug? Maybe?
>
> I'm using a bleeding edge build of gnuplot from
>
>     https://github.com/gnuplot/gnuplot/commit/ca59a14e94df23008200f34cdb7ea8bc017ad946
>
> Plotting a matrix of numbers as points with varying colors works ok:
>
>     plot '-' matrix using 1:2:3 notitle with points pt 7 ps 2 palette
>     1 2 3
>     4 5 6
>     e
>
> I get 6 points in a grid, with different colors. I would expect that
> plotting the same thing 'with labels' should work too, but with printed
> text instead of points
>
>     plot '-' matrix using 1:2:3 notitle with labels
>     1 2 3
>     4 5 6
>     e
>
> I get the grid of printed text, but each "point" is "6" and not "1",
> "2", ...
>
> Bug?

"with labels" wants a string, not a number.
This should work:

  plot '-' matrix using 1:2:(sprintf("%d",column(3))) with labels

I have no idea why it prints "6" though.  That's a mystery.
       
        Ethan

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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
|  
Report Content as Inappropriate

Re: 2d matrix plots 'with labels'

Dima Kogan
sfeam <[hidden email]> writes:

> On Wednesday, 26 July 2017 14:49:07 Dima Kogan wrote:
>>
>> Plotting a matrix of numbers as points with varying colors works ok:
>>
>>     plot '-' matrix using 1:2:3 notitle with points pt 7 ps 2 palette
>>     1 2 3
>>     4 5 6
>>     e
>>
>> I get 6 points in a grid, with different colors. I would expect that
>> plotting the same thing 'with labels' should work too, but with printed
>> text instead of points
>>
>>     plot '-' matrix using 1:2:3 notitle with labels
>>     1 2 3
>>     4 5 6
>>     e
>>
>> I get the grid of printed text, but each "point" is "6" and not "1",
>> "2", ...
>>
>> Bug?
>
> "with labels" wants a string, not a number.
> This should work:
>
>   plot '-' matrix using 1:2:(sprintf("%d",column(3))) with labels
>
> I have no idea why it prints "6" though.  That's a mystery.

Hmmm. I can replace the 1,2,3 thing with aaa,bbb,ccc, and it still
prints the last one. And this works ok for non-matrix plots, so it
sounds like a misbehavior to me. I'll try to find the time to look
through the sources and fix it; hopefully.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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
|  
Report Content as Inappropriate

Re: 2d matrix plots 'with labels'

Gnuplot - Dev mailing list
On Wednesday, 26 July 2017 17:26:05 Dima Kogan wrote:

> sfeam <[hidden email]> writes:
>
> > On Wednesday, 26 July 2017 14:49:07 Dima Kogan wrote:
> >>
> >> Plotting a matrix of numbers as points with varying colors works ok:
> >>
> >>     plot '-' matrix using 1:2:3 notitle with points pt 7 ps 2 palette
> >>     1 2 3
> >>     4 5 6
> >>     e
> >>
> >> I get 6 points in a grid, with different colors. I would expect that
> >> plotting the same thing 'with labels' should work too, but with printed
> >> text instead of points
> >>
> >>     plot '-' matrix using 1:2:3 notitle with labels
> >>     1 2 3
> >>     4 5 6
> >>     e
> >>
> >> I get the grid of printed text, but each "point" is "6" and not "1",
> >> "2", ...
> >>
> >> Bug?
> >
> > "with labels" wants a string, not a number.
> > This should work:
> >
> >   plot '-' matrix using 1:2:(sprintf("%d",column(3))) with labels
> >
> > I have no idea why it prints "6" though.  That's a mystery.
>
> Hmmm. I can replace the 1,2,3 thing with aaa,bbb,ccc, and it still
> prints the last one.

There is no provision for a matrix to hold anything but floating point
numbers, so I would not expect anything useful from trying to fill
one with aaa bbb ccc etc.  (Unless maybe it interprets them as
hexidecimal constants?)

> And this works ok for non-matrix plots,

Sure.  The limitation arises specifically from what can be read in as a matrix.

> so it sounds like a misbehavior to me.

Well, if you could store strings in the matrix then yes "with labels" should
print them.  But so for you are limited to floats.
Do you see a need to read in a matrix of strings?

        Ethan

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Loading...