Message Boards Message Boards

Package for Radar Charts

Posted 9 years ago

RadarChart Mathematica Package

The RadarChart mathematica package incorporates Radar Charts (also known as Spider Charts, Web Charts and Star Plots) as a new set of visualization tools into the mathematica environment.

A detailed explanation on the use of radar charts can be found in the following wikipedia page.

The project is listed at the mathematica package repository (http://packagedata.net), or can be accessed directly at github.

Thanks to halirutan for his guidance on setting up this project. Installation Instructions are heavily based on his existing projects.


Navigation


doc image Detailed Usage

RadarChart[{y1,y2,y3,...}]

generates a radar plot (also known as web, star, spider, cobweb or kiviat diagram) corresponding to a list of values. This type of chart is suitable for showing commonality and outliers across different variables. RadarChart[{list1,list2,...}] generates a radar plot to compare several series.

 RadarChart[association]

generates a radar plot to view the variable values in an association.

 RadarChart[{association1,association2,...}]

generates a radar plot to compare several series.

 RadarChart[dataset]

generates a radar plot to compare several series.

Options are listed in the help file, and also in the readme document @ the github site.

Examples

Needs["RadarChart`"]
RadarChart[{1, 2, 4, 5, 3}, 
ChartLegends -> {"Private Label Strawberry Juice"}, 
AxesLabel -> {"Ripe", "Green", "Candy", "Juicy", "Sulphur"}, 
PlotLabel -> Style["Sensory Map Strawberry Juice", Bold, Large], 
ImageSize -> Medium]

Basic Example

Multiple Series can be charted.

 Needs["RadarChart`"]
 RadarChart[{{1, 4, 3, 5, 2}, {2, 4, 3, 2, 1}}, Filling -> Axis, 
     AxesLabel -> {"Sweet", "Sour", "Salty", "Bitter", "Umami"}, 
     PlotStyle -> {Red, Blue}, ChartLegends -> {"Fernet-Cola", "Jugo"}]

Mathematica graphics

Example of a start plot.

 Needs["RadarChart`"];
 RadarChart[{{1, 4, 3, 5, 2}, {2, 4, 3, 2, 1}}, AxesType -> "Star"]

Mathematica graphics

Compare survey results.

 Needs["RadarChart`"];
 RadarChart[{{3, 4, 3, 4, 2}, {4, 5, 4, 5, 3}}, 
     AxesLabel -> {"Assets", "Reliability", "Cost Control", 
     "Abstenteeism", "Revenue"}, 
     ChartLegends -> {"Past Year", "Current Year"}, Filling -> Axis, 
     PlotStyle -> {{Gray}, {Black}}, ImageSize -> Medium]

Mathematica graphics

Neat Examples

Analyze and compare crime statistics across states.

 Needs["RadarChart`"];
 states = EntityClass["AdministrativeDivision", "AllUSStatesPlusDC"];
 stateNames = First@StringSplit[#, ","] & /@ states["Name"];
 crimeProps = {"AggravatedAssaultRate", "BurglaryRate", 
     "ForcibleRapeRate", "LarcenyTheftRate", 
     "MurderNonnegligentManslaughterRate", "PropertyCrimeRate", 
     "RobberyRate", "ViolentCrimeRate"};
 crimeData = EntityValue[states, 
     EntityProperty["AdministrativeDivision", #] & /@ crimeProps];
 crimeRanking = Transpose[
     Ordering[crimeData[[All, #]]] & /@ Range@Length@crimeProps];
 ds = Dataset[
     AssociationThread[stateNames, 
         AssociationThread[crimeProps, #] & /@ crimeRanking]];
 GraphicsRow[{RadarChart[ds["Georgia"], AxesType -> "Star", 
     PlotLabel -> Style["Georgia", Bold, Large], 
     Epilog -> {Dashed, Circle[{0, 0}, 25.5]}, ImageSize -> Large], 
     GraphicsGrid[
         Partition[
             RadarChart[ds[#], PlotLabel -> #, AxesLabel -> None, 
             PlotRange -> {0, 50}, AxesType -> "Star",
             PlotRangePadding -> Full, FrameTicks -> None, 
             Epilog -> {Dashed, Circle[{0, 0}, 25.5]}] & /@ stateNames, 
             UpTo[6]], ImageSize -> 600]}]]

Mathematica graphics

Installation

This package should work with Mathematica >8 if not using associations or datasets. The package was developed using mathematica 10. The installation is simple: Copy the RadarChart package directory into a location where Mathematica can find it. Usually this is the Applications directory in your $UserBaseDirectory. Just evaluate

FileNameJoin[{$UserBaseDirectory, "Applications"}]

to see it. If there is an old installation of the RadarChart, remove it. Please find detailed steps below.

Automatic Installation for Mathematica 9 and above

We have set up an installation script that does all the steps, except deleting old installations, for you. If it finds an old installation, it will prompt you with the location and quit, so that you can remove the old installation. After removing the old files, just start it again and it will proceed through all the steps pointed out in the manual installation section. To start the installation script, simply call

Import["http://tinyurl.com/ntmhkca"]

After this, the package should be available in your mathematica instance.

Manual Installation

Removing old Installations

Old installation packages can be found by simply searching directories in your $Path.

FileNames["RadarChart", $Path]

Please remove old installation directories that appear after evaluating the commands above. You can use

DeleteDirectory[dir, DeleteContents -> True]

for that, but note that on Windows this might fail, because there, some files are locked when Mathematica is running. In this case, close Mathematica and do it manually using an explorer.

Downloading, Extracting and Copying the New Version

The easiest way is, to download the whole repository as zip file. Use this master.zip or click the Download ZIP on the right side on this page.

After you have downloaded the file extract it. If you have no tool for this on Windows, you could use the free 7-Zip. Under Mac OSX and Linux this should work out of the box.

Inside the extracted directory, you will find a subdirectory RadarChart which has the following structure

RadarChart/
??? Documentation
?   ??? English
?       ??? ReferencePages
?           ??? Symbols
?               ??? RadarChart.nb
??? Kernel
?   ??? init.m
??? Installer.m
??? pacletInfo.m
??? RadarChart.m

Copy the whole RadarChart directory with all its content to your Applications folder under your $UserBaseDiretory. If everything is in place proceed to the next step.

Finishing the Installation

To make the package works, you can simply restart Mathematica.

contact team Contact

If you find bugs or have any other questions, please create a new issue in the bug-tracker.

POSTED BY: Diego Zviovich
13 Replies

@Diego Zviovich this is absolutely stunning, - both the package and the way you documented here its usage. Thank you for making such an exemplary post. I added it it also to Mathematica AddOns and Know-How groups. Are you the author of the package and owner of the linked GitHub repository? I also think we should take the skeleton markdown code for your wonderful doc-like post and make it available to everyone.

POSTED BY: Vitaliy Kaurov
Posted 9 years ago

What a marvelous Christmas present. Thank you very much, Diego!

Kind regards, David

POSTED BY: David Keith
Posted 9 years ago

Hi Vitaly,

Yes, I wrote the package as an exercise for learning to use the Mathematica workbench (very cool) and the Github Site.

Regarding the documentation and installer, I borrowed heavily from @Patrick Scheibe's github repository. so kudos to him for setting up such high standards.

POSTED BY: Diego Zviovich
Posted 9 years ago

Thanks David!

POSTED BY: Diego Zviovich

This is wonderful, Diego! Thank you very much for sharing (and documenting!) the RadarChart package.

Merry Christmas and Happy Holidays!

RadarChart[{aux = Join[{10}, #, Reverse@#] &@{8, 8, 7, 8, 9, 2, 1, 1},
   Join[{0}, #, Reverse@#] &@{0, 0, 0, 0, 0, 0, 0, 10}}, 
 Filling -> Axis, PlotStyle -> {Green, Brown}, 
 Epilog -> {Red, PointSize[0.02], 
   Point[MapIndexed[
     FromPolarCoordinates@{N@#1, 
        bux = Mod[(First[N@#2] - 1)*2 Pi/Length[aux], 2 Pi] + Pi/2; 
        If[bux > Pi, bux - 2 Pi, bux]} &, 
     Join[aux, 0.7*aux, 0.4*aux]]]}, ChartLegends -> None, 
 AxesLabel -> None]

enter image description here

PS - why is PolarCoordinates limited between -Pi and Pi?

POSTED BY: Pedro Fonseca
Posted 9 years ago

Feliz Natal Pedro!

POSTED BY: Diego Zviovich

Few suggestions:

  • Filling from curve to curve like Filling -> {1 -> {2}}

  • AxesType -> "Star" should not remove circular gridlines

  • Mesh -> All and Joined->False for display by points

POSTED BY: Vitaliy Kaurov

I'd like to share an application built with @Jason Biggs about radar chart of sunrise/sunset times for a year :

Needs["RadarChart`"]

sunRadarChart[city_, year_: Automatic, timezone_: Automatic] :=

 Module[{month, set, rise, yr, tz, f, place},

  place = Interpreter["City"][city];
  f[l_] := N[l[[1]] + l[[2]]/60];
  tz = timezone /. Automatic -> LocalTimeZone[place];
  yr = year /. Automatic -> (First@DateList[]);
  month = DateRange[DateObject[{yr}], DateObject[{yr + 1}], Quantity[1, "Months"]];
  set = f[TimeObject[Sunset[GeoPosition[place], #, TimeZone -> tz]][[1]]] & /@ month;
  rise = f[TimeObject[Sunrise[GeoPosition[place], #, TimeZone -> tz]][[1]]] & /@ month;

  RadarChart[{set, rise}, AxesLabel -> (DateString[#, "MonthRomanNumeral"] & /@ month),
   Filling -> Axis, PlotStyle -> {Green, Red}, ImageSize -> 220,
   AxesLabel -> (DateString[#, "MonthRomanNumeral"] & /@ month),
   PlotLabel -> CommonName@place, ChartLegends -> False]]

ParallelMap[sunRadarChart, 
{"Boston", "Nome, USA", "Rio Gallegos, Argentina", "Cape Town", 
  "Dunedin, New Zealand", "Tokio", "Dubai", "Fargo, USA", "Nairobi"}]

enter image description here

POSTED BY: Vitaliy Kaurov
Posted 8 years ago

Good points for the improvements, I'll take a look at the code to start adding the requested features.

POSTED BY: Diego Zviovich
Posted 8 years ago

Two out of three points addressed:

AxesType -> "Star" no longer removes circular gridlines

Mesh -> All and Joined->False for display by points enabled.

RadarChart[{{2, 2, 4, 1, 3}, {4, 3, 6, 2, 3}, {1, 2, 3, 7., 4}}, 
 ChartLegends -> None, PlotLabel -> "Left", AxesType -> "Star", 
 Filling -> Bottom]

enter image description here

RadarChart[table[[1, 2 ;;]], AxesLabel -> Rest@prop, 
 ChartLegends -> None, AxesType -> "Star", PlotRange -> {0, 50}, 
 PlotLabel -> table[[1, 1]], ImageSize -> Large, Joined -> False, 
 PlotStyle -> {{Red, PointSize[Large]}}, 
 Epilog -> {Dashed, Circle[{0, 0}, 25.5]}]

enter image description here

POSTED BY: Diego Zviovich

Very nice, @Diego Zviovich, thank you !

POSTED BY: Vitaliy Kaurov

enter image description here - another post of yours has been selected for the Staff Picks group, congratulations !

We are happy to see you at the top of the "Featured Contributor" board. Thank you for your wonderful contributions, and please keep them coming!

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract