2
$\begingroup$

Maybe not a very descriptive title, but I wasn't sure how to pin it down. What I have is an array of vectors, a numerical example of which would be

vectors = 
  {{0.5, -0.5, 0.5, -0.5}, 
   {0.707107, 1.60288*10^-15, -0.707107, 0.}, 
   {2.11636*10^-15, -0.707107, 4.996*10^-16, 0.707107}, 
   {-0.5, -0.5, -0.5, -0.5}}

What I then do is plot these in a circular fashion, on a disk

EVDisk[vec_, vn_, x_, y_, θ0_, θ1_] := 
 Graphics[{
   Which[
     Sign[vec[[vn]]] == 1, RGBColor[228/255, 26/255, 2/255], 
     Sign[vec[[vn]]] == -1, RGBColor[55/255, 126/255, 184/255]], 
   {EdgeForm[Thickness[Small]], Disk[{x, y}, Abs[vec[[vn]]]^(1/2), {θ0, θ1}]}}]

Show[
  Table[
    EVDisk[
      vectors[[n]], 
      m, 
      Which[
        n == 1 || n == 3, 1, 
        n == 2 || n == 4, 3], 
      If[n == 1 || n == 2, 1, -1], 
      (m - 1)*2*Pi/Length[vsorted[[n]]], 
      m*2*Pi/Length[vsorted[[n]]]], 
    {m, 1, Length[vsorted]}, {n, 1, Length[vsorted]}], 
  FrameTicks -> None, Frame -> True]

Which looks something like this (apart from the legend)

enter image description here

But what I want it to look like is

enter image description here

I made the second image in photoshop, but its tedious and kind of screws up the quality. So I'm wondering if someone could help me out on where to start with doing this inside Mathematica itself. I'm honestly not even sure if it possible, but I guess there must be a clever way to do it, probably part of it in the definition of EVDisk (the 1-4 part) I suppose.

Could anyone help me start?

$\endgroup$
4
  • 1
    $\begingroup$ regarding the quality - If you export the image as eps and then open it in photoshop with 300 resolution, do your edit and then save as jpg, you would get a much better quality final image. $\endgroup$
    – Hubble07
    Aug 9, 2015 at 16:38
  • 3
    $\begingroup$ Did you try to use Text? $\endgroup$
    – Sungmin
    Aug 9, 2015 at 16:45
  • 4
    $\begingroup$ Maybe you should also look into SectorChart. $\endgroup$
    – Jens
    Aug 9, 2015 at 16:48
  • $\begingroup$ The definition of vsorted is missing. Is it the same as vectors? $\endgroup$
    – Federico
    Aug 9, 2015 at 21:45

1 Answer 1

2
$\begingroup$

You can use something like

{Black, Text[Style[vn, 16, Bold],
  {x + .3 Cos[(θ0 + θ1)/2], y + .3 Sin[(θ0 + θ1)/2]}]}}

to print vn in font Bold with fontsize 16, located near $(x,y)$, at distance $0.3$ in direction $(\theta_0+\theta_1)/2$.

For instance:

EVDisk[vec_, vn_, x_, y_, θ0_, θ1_] := 
 Graphics[{Which[Sign[vec[[vn]]] == 1, 
    RGBColor[228/255, 26/255, 2/255], Sign[vec[[vn]]] == -1, 
    RGBColor[55/255, 126/255, 184/255]], {EdgeForm[Thickness[Small]], 
    Disk[{x, y}, Abs[vec[[vn]]]^(1/2), {θ0, θ1}]},
   {Black, 
    Text[Style[vn, 16, Bold], {x + .3 Cos[(θ0 + θ1)/2], 
      y + .3 Sin[(θ0 + θ1)/2]}]}}
  ]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.