plotting market cap heatmap

3 messages Options
Embed this post
Permalink
Khanh Nguyen

plotting market cap heatmap

Reply Threaded More More options
Print post
Permalink
Hi,

Let say I have this data frame.

> tickers <- toupper(letters[1:5])
> market.cap <- c(100, 60, 700, 1500, 450)
> change <- c(0.02, 0.004, 0.0012, 0.001, 0.030
> data <- data.frame(tickers, market.cap, change)
> data
  tickers market.cap change
1       A        100 0.0200
2       B         60 0.0040
3       C        700 0.0012
4       D       1500 0.0010
5       E        450 0.0300

and I'd like to plot a heatmap whose market cap is proportional to the
size of the cell, similar to http://finviz.com/map.ashx. Could
somebody please give me a pointer? Thanks.

-k

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Brian G. Peterson

Re: plotting market cap heatmap

Reply Threaded More More options
Print post
Permalink
The only heatmap code I've used in R is based on correlations, usually
paired with a dendogram.  I don't know if that code could be adapted.

Maybe a question for r-help since this seems a bit more generally
related to plotting things in R than the specifics of what you're plotting?

Regards,

   - Brian

Khanh Nguyen wrote:

> Hi,
>
> Let say I have this data frame.
>
>  
>> tickers <- toupper(letters[1:5])
>> market.cap <- c(100, 60, 700, 1500, 450)
>> change <- c(0.02, 0.004, 0.0012, 0.001, 0.030
>> data <- data.frame(tickers, market.cap, change)
>> data
>>    
>   tickers market.cap change
> 1       A        100 0.0200
> 2       B         60 0.0040
> 3       C        700 0.0012
> 4       D       1500 0.0010
> 5       E        450 0.0300
>
> and I'd like to plot a heatmap whose market cap is proportional to the
> size of the cell, similar to http://finviz.com/map.ashx. Could
> somebody please give me a pointer? Thanks.
>
> -k
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Peter Carl-2

Re: plotting market cap heatmap

Reply Threaded More More options
Print post
Permalink
In reply to this post by Khanh Nguyen
These kinds of things are sometimes called "treemaps".  Take a look at the
'portfolio' package, particularly at the function called 'map.market'.

pcc
--
Peter Carl
http://www.braverock.com/~peter

> Hi,
>
> Let say I have this data frame.
>
>> tickers <- toupper(letters[1:5])
>> market.cap <- c(100, 60, 700, 1500, 450)
>> change <- c(0.02, 0.004, 0.0012, 0.001, 0.030
>> data <- data.frame(tickers, market.cap, change)
>> data
>   tickers market.cap change
> 1       A        100 0.0200
> 2       B         60 0.0040
> 3       C        700 0.0012
> 4       D       1500 0.0010
> 5       E        450 0.0300
>
> and I'd like to plot a heatmap whose market cap is proportional to the
> size of the cell, similar to http://finviz.com/map.ashx. Could
> somebody please give me a pointer? Thanks.
>
> -k
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.