1

I want to draw a MatrixPlot and replace the FrameTicks with cities names, as shown bellow. The problem is that FrameTicks uses the string center to position it in the respective tick, which results in a bad alignment in the top section. How can I set it to use the left justified text?

ListaCidades = {"Aveiro", "Açores", "Beja", "Braga", "Bragança", 
   "Castelo Branco", "Coimbra", "Évora", "Faro", "Guarda", "Leiria", 
   "Lisboa", "Madeira", "Portalegre", "Porto", "Santarém", "Setúbal", 
   "Viana do Castelo", "Vila Real", "Viseu"};

MatrixPlot[Data1, 
 FrameTicks -> {{{#, Style[ListaCidades[[#]], 12]} & /@ Range[20], 
    None}, {None, {#, 
       Rotate[Style[ListaCidades[[#]], 12], 45 Degree]} & /@ 
     Range[20]}}, ImageSize -> Large]

enter image description here

corey979
  • 23,947
  • 7
  • 58
  • 101
Miguel
  • 981
  • 5
  • 13
  • I think is only similar but not quite the same. That one is asking to align to the center and from the replies I can't figure it out how to adapt to my problem. – Miguel Sep 21 '17 at 11:47

1 Answers1

4

Like this:

ListaCidades = {"Aveiro", "Açores", "Beja", "Braga", "Bragança", 
   "Castelo Branco", "Coimbra", "Évora", "Faro", "Guarda", "Leiria", 
   "Lisboa", "Madeira", "Portalegre", "Porto", "Santarém", "Setúbal", 
   "Viana do Castelo", "Vila Real", "Viseu"};
Data1 = RandomReal[{0, 1}, {Length@ListaCidades, Length@ListaCidades}];

center = Row[{Invisible[#], #}, "\[NegativeThickSpace]"] &;

MatrixPlot[Data1, 
 FrameTicks -> {{{#, Style[ListaCidades[[#]], 12]} & /@ Range[20], 
    None}, {None, {#, 
       center@Rotate[Style[ListaCidades[[#]], 12], 45 Degree]} & /@ 
     Range[20]}}, ImageSize -> Large]

enter image description here

corey979
  • 23,947
  • 7
  • 58
  • 101