Histogram with dates on x-axes
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
Histogram with dates on x-axes
I have the transaction dates of investors and want to do a histogram showing the frequency of trading at each date. However, the histogram automatically makes the dates into numbers and then you cannot read the graph. How do I get the histogram to show dates (i.e 2005-12-30) on the bottom axis?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Histogram with dates on x-axes
Could you provide your workfile? I'm having a hard time picturing what you're doing (maybe it is just too early in the morning for me!)
Re: Histogram with dates on x-axes
Here's the workfil. It's pretty basic, I just want to see the frequency of trades at each date. Hence, the code is the standard "first_tradedate.distplot" which works fine except for the fact that the dates are converted into numbers. Many thanks for the help.
- Attachments
-
- trans_jan11.wf1
- (22.42 KiB) Downloaded 364 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Histogram with dates on x-axes
Ah, I see what you mean now. I can't think of an easy way around that.
The complicated way is as follows. From the series use Proc->Make Distribution Data. This will give you a matrix containing the data used to make the histogram. You can then create a new workfile page that contains the same number of observations as rows in that matrix (32 when I just did it on your workfile). You then copy the matrix over to the new page, and use the mtos function to convert the matrix into series. You'll end up with three series, one containing the lower date, one containing the upper date, and one containing the frequency. You could then make a bar chart out of the frequency series, and use the end series as custom date labels for that bar chart.
I've attached the quick one I did, here.
The complicated way is as follows. From the series use Proc->Make Distribution Data. This will give you a matrix containing the data used to make the histogram. You can then create a new workfile page that contains the same number of observations as rows in that matrix (32 when I just did it on your workfile). You then copy the matrix over to the new page, and use the mtos function to convert the matrix into series. You'll end up with three series, one containing the lower date, one containing the upper date, and one containing the frequency. You could then make a bar chart out of the frequency series, and use the end series as custom date labels for that bar chart.
I've attached the quick one I did, here.
- Attachments
-
- trans_jan11.wf1
- (29.26 KiB) Downloaded 357 times
Re: Histogram with dates on x-axes
Thanks. I'm new to Eviews and I don't know how to set the data labels to the end date series. What would the code be that puts the end dates on the x-axis?
"graph graph01.bar freq" obviously isn't enough, then I'm just stuck with a graph with the same problem I started with - no dates on x-axis! :) (It's Friday afternoon here and now I just want to go home!!)
"graph graph01.bar freq" obviously isn't enough, then I'm just stuck with a graph with the same problem I started with - no dates on x-axis! :) (It's Friday afternoon here and now I just want to go home!!)
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Histogram with dates on x-axes
This is the full set of code that would replicate what I did:
Code: Select all
FIRST_TRADEDATE.distdata(dtype=hist) matrix01
!rows = @rows(matrix01)
pagecreate(page=page2) u !rows
copy Trans_jan11\matrix01 page2\matrix01
mtos(matrix01, g)
rename ser01 start
rename ser02 end
rename ser03 freq
end.setformat "dd/mm/yyyy"
freeze(graph01) freq.bar
graph01.setobslabel(series) end
Who is online
Users browsing this forum: No registered users and 2 guests
