MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: WorldPlot and excel data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89825] Re: WorldPlot and excel data
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 21 Jun 2008 05:33:10 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <g3g006$kv4$1@smc.vnet.net> <485BA4C5.7070706@gmail.com>

Jean-Marc Gulliet wrote:

> DBK wrote:
> 
>> This should be simple but I'm stumped. I am just trying to read in
>> country names (column 5) and associated colors (column 5). The color
>> column is just a single column of Black, Black, White, Red etc. Below
>> is my code and the error it generates. Any ideas what I am doing
>> wrong?
>>
>> << WorldPlot`
>> remotemap = Import["remote.xls"][[1]];
>> remotemap1 = remotemap[[All, 5]]
>> remotemap2 = remotemap[[All, 4]]
>> finalmap = WorldPlot[{remotemap1, remotemap2}]
>>
>> WorldPlot::badshades: WorldPlot shading \
>> {Black,Black,Black,Black,Black,Black,Black,Black,Black,Black,<<159>>}
>> \
>> is not valid. Shading should consist of a list of Mathematica color \
>> primitives such as RGBColor or Hue, or of a function that generates \
>> such colors when applied to country names.
> 
> 
> You should post a working example that can be evaluated by others and 
> that generates above mentioned error. (Your version of Mathematica might 
> help too.)
> 
> The following works as expected on my system.
> 
>     << WorldPlot`
>     remotemap1 = {"Canada", "Mexico"};
>     remotemap2 = {Orange, Black};
>     finalmap = WorldPlot[{remotemap1, remotemap2}]
>     $Version
> 
>     [... nice orange and black graphic deleted ...]
> 
>     "6.0 for Mac OS X x86 (64-bit) (February 7, 2008)"

Just an afterthought, but I believe that after importing from Excel, 
remontemap2 is a list of *strings*. On the other hand, WorldPlot expect 
a list of *symbols*. One can convert strings into symbols thanks to the 
function *ToExpression[]*. Since ToExpression[] is listable, you could 
write,

     remotemap2 = ToExpression[remotemap[[All, 4]]]


For instance, the following code,

<< WorldPlot`
remotemap1 = {"Canada", "Mexico"};
remotemap2 = ToExpression /@ {"Orange", "Black"};
finalmap = WorldPlot[{remotemap1, remotemap2}]

works fine while this one returns the same error message as yours,

<< WorldPlot`
remotemap1 = {"Canada", "Mexico"};
remotemap2 = {"Orange", "Black"};
finalmap = WorldPlot[{remotemap1, remotemap2}]


HTH,
-- Jean-Marc


  • Prev by Date: Re: Problem with Mesh for MatrixPlot
  • Next by Date: Re: Combining pure functions to produce a new pure
  • Previous by thread: Re: WorldPlot and excel data
  • Next by thread: Question - Cluster Analysis