How to assign labels to observations in a scatter plot?
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
How to assign labels to observations in a scatter plot?
Hi,
I'm trying to create a scatter plot graph. The data is like below: (country is an alpha series and gdp and inflation are numerical series.)
GDP inflation country
11 2 Australia
12 3 Austria
13 3 Belgium
10 4 Brazil
8 5 Chile
I want to make a scatpair chart so that x axis is gdp and y axis is inflation. What's more, I want
country names to show up next to each observation plot.
I tried the scarpair command like this:
group graph1 gdp inflation
graph1.scatpair
The problem is that I can't find a way to show country names next to each spot in the
graph. (I tried to use symbol commnad but it's not working).
Is there a way I can do it?
Thanks in advance.
I'm trying to create a scatter plot graph. The data is like below: (country is an alpha series and gdp and inflation are numerical series.)
GDP inflation country
11 2 Australia
12 3 Austria
13 3 Belgium
10 4 Brazil
8 5 Chile
I want to make a scatpair chart so that x axis is gdp and y axis is inflation. What's more, I want
country names to show up next to each observation plot.
I tried the scarpair command like this:
group graph1 gdp inflation
graph1.scatpair
The problem is that I can't find a way to show country names next to each spot in the
graph. (I tried to use symbol commnad but it's not working).
Is there a way I can do it?
Thanks in advance.
-
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?
Code: Select all
graph1.setelem(1) symbol(obslabel)
-
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?
One comment. The workfile needs to be structured as undated with ID series set to the COUNTRY series.
Re: How to assign labels to observations in a scatter plot?
I know how to change the frequency to u, but how to change the id series to be "country"?
pagestruct(freq=u) @id(country) ?
pagestruct(freq=u) @id(country) ?
-
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?
Code: Select all
pagestruct country
Re: How to assign labels to observations in a scatter plot?
I tried pagestruct country,
It gives an error saying that "indices do not uniquely identify observations".
I reduced the sample so that there are only three countries whose names are obviously different.
It gives an error saying that "indices do not uniquely identify observations".
I reduced the sample so that there are only three countries whose names are obviously different.
-
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?
You have to remove the duplicate observations from the workfile page (using pagecontract) entirely, rather than from the sample.
-
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?
If you don't want to actually structure your workfile by the country series, you can do this:
Code: Select all
graph1.setobslabel(series) country
Re: How to assign labels to observations in a scatter plot?
I guess what you are saying is that there should be no dots that have the same
coordinates but different country names? for that I can understand, since two country names would then overlap. but the fact is there is no dots
that share the same coordinates in my series(as you can see in my example).
can you possibly specify what you mean by "removing all the duplicate observations"?
I just also tried the new way: by using graph1.setobslabel(gdp) country,
it says "setobslabel is not a valid view for graph1.
(I removed the (gdp) and it results in the same. )
Many thanks.
coordinates but different country names? for that I can understand, since two country names would then overlap. but the fact is there is no dots
that share the same coordinates in my series(as you can see in my example).
can you possibly specify what you mean by "removing all the duplicate observations"?
I just also tried the new way: by using graph1.setobslabel(gdp) country,
it says "setobslabel is not a valid view for graph1.
(I removed the (gdp) and it results in the same. )
Many thanks.
-
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?
Try:
The series part should not be replaced.
Code: Select all
graph1.setobslabel(series) country
Re: How to assign labels to observations in a scatter plot?
I used the command below exactly, but the program keeps telling me that "setobslabel is not a valid view for graph1".
graph1.setobslabel(series) country
graph1.setobslabel(series) country
-
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?
graph1 needs to be a graph object, not a group. You can't do it on a group.
Re: How to assign labels to observations in a scatter plot?
I just noticed that.
I changed the project to be the graph name rather than the group name. this time there is no error.
But still it doesn't have the country name next to the points. I guess right now the scatpair can not
build any connection between the graph and the third alpha series "country".
I found a chart on eviews help-> basic customization. The "lines and symbols " section gave an exact type of graph
I need, (Matthews(2000) data and storks.wf1). It shows how to do it by clicking but not by commanding.
I changed the project to be the graph name rather than the group name. this time there is no error.
But still it doesn't have the country name next to the points. I guess right now the scatpair can not
build any connection between the graph and the third alpha series "country".
I found a chart on eviews help-> basic customization. The "lines and symbols " section gave an exact type of graph
I need, (Matthews(2000) data and storks.wf1). It shows how to do it by clicking but not by commanding.
-
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?
Code: Select all
create u 20
series x=nrnd
series y=nrnd
alpha country = "h"
group g x y
freeze(graph1) g.scatpair
graph1.setelem(1) symbol(obslabel)
graph1.setobslabel(series) country
show graph1
Re: How to assign labels to observations in a scatter plot?
I tried your program and it helped a lot in my program: there are
a lot of "h" showing up in the graph. Similar to my graph, different country names
are on the graph. the only thing right now is that the original symbol, which are the
small round dots, are gone.
Can I have both the dots and the name next to it? (you can see that the above program
gives h but no circles or dots for each observation.)
Thanks so much.
a lot of "h" showing up in the graph. Similar to my graph, different country names
are on the graph. the only thing right now is that the original symbol, which are the
small round dots, are gone.
Can I have both the dots and the name next to it? (you can see that the above program
gives h but no circles or dots for each observation.)
Thanks so much.
- Attachments
-
- example.png (34.3 KiB) Viewed 13134 times
Who is online
Users browsing this forum: No registered users and 2 guests
