Hi John,
a couple of years ago, I've written a package "plot_scatter_label".
Unfortunately, it's not on the package server any more -- I don't know
why.
But here is the code plus an example:
<hansl>
clear
set verbose off
function string AddLabel (series Y,
series X,
strings LABEL)
matrix XY = {Y}~{X}
string S = ""
loop i=1..rows(XY) -q
s = sprintf("set label $i '%s' at %.4f-0.1, %.4f-0.2 centre font
',10' ; ",\
LABEL[$i], XY[i,2],XY[i,1])
S += s
endloop
return S
end function
open mrw.gdt --quiet
smpl 1 3
strings C = array(3)
C[1] = "Algeria"
C[2] = "Angola"
C[3] = "Benin"
string GP = AddLabel(gdpgrow,school, C)
# Actual Plot
list lplot = gdpgrow school
plot lplot
literal set term png font 'Helvetica,12' lw 1
literal set nokey
literal set title ''
literal set xrange[0:]
literal set linetype 1 lc rgb 'blue' pt 7 ps 1
literal @GP
end plot --output=display
</hansl>
Am 01.06.2022 07:55 schrieb John Paravantis:
> I am talking about adding the values of a qualitative variable, e.g.
> country codes, as labels.
>
> As an example from my megacity research, imagine a scatter plot of
> carbon footprint (y-axis) vs city population (x-axis). In such a plot,
> it would be very useful if the data points were labeled with the
> megacity name.
>
> So I am suggesting that two separate improvements be considered for
> gretl:
>
> (1) Add the capability of handling qualitative (i.e. text) variables,
> something that is sorely missing right now. I have to manually delete
> columns containing text from Excel files that I want to open in gretl,
> which is inconvenient. If anything else, gretl could ignore such
> columns, not give an error and refuse to open such a file.
> (2) Add the capability of adding a qualitative variable as labels of
> the points of a scatter plot.
>
> Many thanks to all for your thoughts,
> John
>
> On Wed, Jun 1, 2022 at 1:00 AM <gretl-users-request(a)gretlml.univpm.it>
> wrote:
>
>> Am 31.05.2022 um 00:19 schrieb John Paravantis:
>>> If I may get back to my suggestion, I understand that it may be
>> possible
>>> to add data labels via commands, but it would appear to me that
>> it would
>>> not be too difficult to add an option of selecting the values of
>> a
>>> variable as labels, since the option of adding labels to
>> individual
>>> points is already built in in the edit dialog of a scatter plot.
>>
>> John, let me ask the more fundamental question, why would one want
>> the
>> values as labels? I mean in a scatter plot the values are on the
>> axes
>> and the location of the data point communicates those values
>> already.
>> OK, sometimes one wants to see the exact digits and then a kind of
>> mouse-over tooltip effect is nice. But really printing/displaying
>> the
>> values right now does not sound to me like a natural GUI feature.
>>
>> cheers
>> sven
>
> _______________________________________________
> Gretl-users mailing list -- gretl-users(a)gretlml.univpm.it
> To unsubscribe send an email to gretl-users-leave(a)gretlml.univpm.it
> Website:
>
https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/