5 new plot commands in Mathematica 8

November 8th, 2010 | Categories: math software, mathematica | Tags:

Mathematica 8 is coming and it’s chock-full of new features.  Last month I took a very brief look at some of the new control systems functionality that we’ll be getting and this time around I thought I would take a look at some of the new plotting functions.

The first new command that I’d like to show you is a revamped box and whisker plot. Mathematica 7 could do these as part of the StatisticalPlots package but they seemed a bit of an afterthought and didn’t have many options.

data1 = RandomReal[NormalDistribution[0, 1], 100];
data2 = RandomReal[{0, 1}, 100];
BoxWhiskerPlot[data1, data2]

Mathematica 7 Box and Whisker
The above code still works in Mathematica 8 but you’ll be told that it’s obsolete. The new way of doing things is to use BoxWhiskerChart which looks better, has a boat load of new options and also comes with a very nice tool-tip.

data = Table[
   RandomVariate[NormalDistribution[mu, 1],
    100], {mu, {0, 3, 2, 5}}];
BoxWhiskerChart[data, ChartElementFunction -> "GlassBoxWhisker"]

Mathematica 8 Box and Whisker

BoxWhiskerChart[RandomVariate[NormalDistribution[], {5, 100}],
 ChartStyle -> "SandyTerrain",
 ChartLegends -> {"a", "b", "c", "d", "e"}]

Mathematica 8 Box and Whisker
Next up is something from the world of Finance – a Kagi Chart.

data = FinancialData["L:LLOY",
   "Close", {{2010, 6, 1}, {2010, 11, 1}, "Day"}];
KagiChart[data, TrendStyle -> {Green, Red}]

Mathematica 8 Kagi Chart
How about some wavelets? Let’s do a discrete wavelet transform of a photo of me and use WaveletImagePlot to show the wavelet image coefficients.

me = Import["me.jpg"];
dwd = DiscreteWaveletTransform[me, Automatic, 3];
WaveletImagePlot[dwd, ImageSize -> 200]

Mathematica 8 WaveletImagePlot
Next up is a plot-type that is completely new to me – A violin plot.

DistributionChart[RandomVariate[NormalDistribution[0, 1], {4, 100}],
 ChartElementFunction ->
  ChartElementData["SmoothDensity", "ColorScheme" -> "DeepSeaColors"]]

Mathematica 8 Violin Plot
Finally, A little more control systems with a Root Locus Plot.

 StateSpaceModel[{{{0, 1}, {-3, -2}}, {{0}, {1}}, k {{2, 1}}}], {k, 0,

Mathematica 8 Root Locus Plot
What I like most about all of these new plot types is that they will be built in to core Mathematica as of version 8 – no add-ons necessary. Compare this to MATLAB which has functions for most of the above plots but only if you buy the relevant toolbox:

  • Box and Whisker Plot – Statistics Toolbox
  • Kagi Chart – Finance Toolbox
  • Wavelet coefficients – Wavelet Toolbox
  • Root locus plot – Control Systems Toolbox
  • Violin Plot – ?????

I much prefer Mathematica’s all in one approach and I am really looking forward to this release.  Thanks to Wolfram Research for allowing me to release this little preview.

How about you?  What plot types are you hoping for in Mathematica 8?

  1. November 8th, 2010 at 23:50
    Reply | Quote | #1

    A function that would plot complex-numbers (real part on one axis, imaginary on the other); implementation should take them 1 hour, tops ;)

    For all 3D-plots and 2D-contour plots the options for Log axes. Either by separate function, or by giving an option like Axes->{“Log”,”Linear”}.

    A nice function for plotting data with errors would also be nice.

    And probably a lot more if I think about it…

  2. Nasser M. Abbasi
    November 9th, 2010 at 00:51
    Reply | Quote | #2

    “I much prefer Mathematica’s all in one approach and I am really looking forward to this release.”

    Ofcourse, this is a better approach. Open the box, and all is in there, no need to buy one piece to do this and another to do that.

    I hope WRI will continue doing this, integrate everything in, because in the end, it is better for us, and will be also better for WRI. I hope WRI will not fall to the idea of short term profit over long term success like other companies seem to do.

    But for me, the main reason I like to use Mathematica has nothing to do with any of this.

    It is because I can write some program in Mathematica, and convert it to a player format, and then any one can run my code, without them having to buy Mathematica or pay anything to run my program. The Mathematica player is free of charge.

    It will be even better if there were no restriction on what can go into the free version of the Player code. This will make Mathematica much more popular.

    With Matlab (which I also like) this player option does not exist. If I write matlab code, and since as a student I have no access to the Matlab compiler, then only those who have Matlab installed on their PC (with all the toolboxes I happened to use) could run the code.

    This is really the main difference for me.

    In addition, Mathematica have the home edition version, Complete Mathematica, which one can buy for $299 for home use. So after school, one can still use Mathematica.

    Matlab has no such option. The person on the street who is not a student and who does not work for large rich company that can afford these commercial products, this person has no option to use Matlab, as most can not afford to buy it at the commercial price.

    Imagine if person A writes a small program, and emails it to person B to run it on their PC, but person B has to go first buy some software for $3,000 to run it. Yes, sure. That will really work.


  3. November 9th, 2010 at 01:02
    Reply | Quote | #3

    Built-ins for plotting complex functions would be nice. Also, multiple Undo capability. Actually, multiple undo issue has come up several time before and WRI’s reply was that it was too hard to implement. That makes me wonder what kind of geniuses created Notepad….

  4. LB
    November 9th, 2010 at 01:42
    Reply | Quote | #4

    DateListBarChart – that can be put on the same plot as an existing DateListPlot line chart, aligned nicely

    Specifying your own colour schemes, so that the first line is always red, the next blue etc

    Coloured backgrounds for the plot area but not the area outside the frame — with the possibility of white gridlines

    The ability to explicitly fix the size of the plot frame, not just the whole graphic

  5. November 9th, 2010 at 21:17
    Reply | Quote | #5

    @LB You specify the size of the plotframe, but not directly:

    Specify an imageSize-> {x,y} and then also give the command ImagePadding->{{left,right},{bottom,top}}
    just like: http://reference.wolfram.com/mathematica/howto/AlignPlotsWithEachOther.html

  6. November 10th, 2010 at 04:31
    Reply | Quote | #6

    Nasser — In Matlab’s defense, with Matlab you can generate standalone executables which work without any extra things to install. On a latest big project at work, my code needed to execute on a remotely managed server farm where I didn’t have control over what got installed, and I ended choosing Matlab because Mathematica doesn’t give such option.

  7. Joplin
    November 10th, 2010 at 12:32
    Reply | Quote | #7

    “What plot types are you hoping for in Mathematica 8?”

    What other plots should we hope for?
    We hope for no more waiting, give people Mathematica 8 now!…

  8. November 10th, 2010 at 13:59
    Reply | Quote | #8

    @Yaroslav but is it cross-platform?

  9. November 10th, 2010 at 15:29
    Reply | Quote | #9

    @Sander – I can answer that since we use the MATLAB compiler a lot here. An individual executable is not cross platform. For example, If you compile using MATLAB on 64bit Linux then you can only deploy to 64bit Linux machines.

    So, if you want to deploy to Linux, Mac and Windows you will need to do three separate compilations on 3 different machines.

  10. November 10th, 2010 at 15:30

    @Joplin I’d love to but it is not within my power. This is mainly because I don’t work for Wolfram Research ;)

  11. Nasser M. Abbasi
    November 10th, 2010 at 18:48

    @Yaroslav Bulatov

    “with Matlab you can generate standalone executables which work without any extra things to install”

    Please read again what I said:

    “If I write matlab code, and since as a student I have no access to the Matlab compiler, then only those who have Matlab installed on their PC (with all the toolboxes I happened to use) could run the code.”

    The average person on the street including students can not afford to buy a commercial product worth $3,000 to have access to the compiler.

    If one works in a large company, then they can afford anything they want. But this is not what I am talking about.


  12. Nasser M. Abbasi
    November 11th, 2010 at 03:13

    @Yaroslav Bulatov

    “and I ended choosing Matlab because Mathematica doesn’t give such option.”

    I did not use the player pro, but using it, according to this link below, one can build a standalone executable using Mathematica.


    it says:

    “And you can choose whether you want to bundle Player Pro to make a stand-alone application or deliver tools to an existing Player Pro user.”

    The playerpro is not free, but so is the Matlab compiler. The point is, it seems there is an option to make stand-alone .EXE applications using Mathemstica.

    I wonder if someone here did use the playerpro to do that, and can comment on this.


  13. November 11th, 2010 at 11:27


    The MATLAB Compiler costs the developer money but the users of the resulting application don’t have to pay a thing.

    With Mathematica Player Pro, the developer doesn’t need to pay anything extra but each user of the application does (they have to get a player pro license).

    Of the two approaches, I have to say that I prefer the MATLAB one most of the time.


  14. Ruben Maas
    November 12th, 2010 at 12:23

    I use the ColorbarPlot package (also mentioned on this blog) quite often to show the scale for a contourplot. Would be nice to have this in Mathematica 8 as standard, since it seems to me a critical addition to the contourplot function.

  15. Pedro Fonseca
    November 12th, 2010 at 15:33

    The price of the Player Pro is completely forbidden for the type of applications I do. I could imagine asking my clients to pay $50 maximum (and some of the times, just $1), but this means that the player pro would have to be free (or almost).

    Due to its current price, I’m not going to distribute my application for the free Mathematica player (cannot encrypt source code); my client will not be able to use it (since I’m not distributing it); Mathematica loses the possibility of getting more popular (my client liking it, and eventually buying the full version).

    The main question is (obviously with no answer): does what W.R. gain from the Pro compensate what it loses on getting Mathematica more popular?


  16. LB
    November 13th, 2010 at 04:11

    Sander, thanks yes this is how I do it now but it would be nice if I could specify the inner frame dimensions and Mathematica would work out how wide the graphic had to be to fit the labels.