How to assign labels to observations in a scatter plot?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: How to assign labels to observations in a scatter plot?

Postby EViews Gareth » Tue Sep 13, 2011 2:40 pm

Look up the setelem command in the object reference.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: How to assign labels to observations in a scatter plot?

Postby EViews Glenn » Wed Sep 14, 2011 9:40 am

If you were to take a look at the setelem entry in the manual, it shows that there is both a

Code: Select all

obslabel
and a

Code: Select all

dotobslabel
the latter of which has both the obs label and the dot as requested. Replace Gareth's obslabel with the dotobslabel.

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Re: How to assign labels to observations in a scatter plot?

Postby Liu » Wed Sep 14, 2011 1:45 pm

Yes I just read the menu and it's actually in the legend. I didn't realize the meaning of the chart
when I was reading it by myself but now it all came clear to me.

Thanks so much for both of you.

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Re: How to assign labels to observations in a scatter plot?

Postby Liu » Thu Sep 15, 2011 8:55 am

I am trying to use the above finds to do something on my chart.

Now I can have a dot with text next to it. My idea is: suppose I plot a series as a line graph.
What I want is to have text showing the last data point in my graph such as (2001m1, 123.45). My initial solution is to graph a
dot plot of only the last observation (by creating a new series that has only one observation), and then plot a line of the opriginal series
in the same graph.

The problem is: eviews doesn't allow dot to be the type of the first series in a "mixed lines" graph. It can only be area or bar.


Is there a way I can achieve that?


(I attached a photo of what I wish, however this is by placing the cursor next to the observation rather than generate a real text box by command).

Many thanks.
Attachments
text.png
text.png (24.72 KiB) Viewed 8912 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: How to assign labels to observations in a scatter plot?

Postby EViews Gareth » Thu Sep 15, 2011 9:02 am

Don't think it can be done.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: How to assign labels to observations in a scatter plot?

Postby EViews Glenn » Thu Sep 15, 2011 9:45 am

You can freeze and add the text label manually, but there's nothing automatic.

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Re: How to assign labels to observations in a scatter plot?

Postby Liu » Thu Sep 15, 2011 11:34 am

yes addtext another way I was thinking. and that leads to another thing.
as you know, graph.addtext(x,y,textcolor) is the command to locate the text box coordinates.
I just wonder if there is a way to let the program to return the coordinates of a certain data point?

for example, for an observation of (123.45,2001q1), is there a way to return the coordinate of this datapoint from the
graph?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: How to assign labels to observations in a scatter plot?

Postby EViews Gareth » Thu Sep 15, 2011 11:37 am

No, which is why it impossible to add the text automatically.

CharlieEVIEWS
Posts: 202
Joined: Tue Jul 17, 2012 9:47 am

Re: How to assign labels to observations in a scatter plot?

Postby CharlieEVIEWS » Tue Jan 20, 2015 5:17 pm

Dear all,

I'm struggling to find the command line/batch syntax to change the font on .setobslabel. For example, taking a minor variation on Gareths example from above (with no alpha series), how would I change the size of the 'h' in the graph here without using the menus?

Code: Select all

create u 20 series x=nrnd series y=nrnd group g x y freeze(graph1) g.scatpair graph1.setelem(1) symbol(obslabel) graph1.setobslabel(series) h h h h h h h h h h h h h h h h h h h h h h h h show graph1
Best wishes as always

Charlie

EViews Jason
EViews Developer
Posts: 870
Joined: Tue Sep 16, 2008 3:50 pm

Re: How to assign labels to observations in a scatter plot?

Postby EViews Jason » Wed Jan 21, 2015 9:15 am

It depends on which h you wish to set the font for.

If you want to change the font for the labels on the axes use

Code: Select all

graph1.setfont axes(20) 'set to 20pt
If you want to change the font for the labels within the graph

Code: Select all

graph1.setfont obs(16) 'set to 16pt


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest