Mathematica How to add legends with 6 or more discrete entries?

  • Thread starter Thread starter Van Ladmon
  • Start date Start date
  • Tags Tags
    Discrete
AI Thread Summary
The discussion centers on an issue with the ArrayPlot function in Mathematica, specifically regarding the behavior of legends when plotting multiplication tables of cyclic groups. Users report that while legends function correctly for the first five graphs, they become problematic starting with the sixth graph, appearing cluttered and resembling a BarLegend. This issue persists when using non-numerical labels, as the legend disappears entirely after six elements. Participants speculate whether there is a maximum limit for legend elements, which is not documented, and suggest that this could be a bug. They also note a potential distinction between PlotLegends and ChartLegends, with the latter working correctly beyond five elements. The recommendation is to submit a bug report to Wolfram to address the issue.
Van Ladmon
Messages
8
Reaction score
0
I want to add legends in ArrayPlot and my code is like this:
Code:
Table[ArrayPlot[
  FiniteGroupData[{"CyclicGroup", i}, "MultiplicationTable"],
  PlotLegends -> Range[i],
  ColorRules -> {x_ -> ColorData["Rainbow"][(x/i)]}],
{i, 1, 10}]
In the first 5 graphs this work well, but after the 6th graph these legends stick together like BarLegend and become somewhat strange. How can I deal with this problem?
 
Physics news on Phys.org
Unless there is a maximum number of elements in a legend, and I couldn't find anything about that in the documentation, it looks like a bug.

If you try to use non-numerical labels, the legend simply disappears when you reach 6
Code:
ArrayPlot[FiniteGroupData[{"CyclicGroup", 6}, "MultiplicationTable"], 
PlotLegends -> {"a", "b", "c", "d", "e", "f"},
ColorRules -> {x_ -> ColorData["Rainbow"][(x/6)]}]
 
DrClaude said:
Unless there is a maximum number of elements in a legend, and I couldn't find anything about that in the documentation, it looks like a bug.

If you try to use non-numerical labels, the legend simply disappears when you reach 6
Code:
ArrayPlot[FiniteGroupData[{"CyclicGroup", 6}, "MultiplicationTable"],
PlotLegends -> {"a", "b", "c", "d", "e", "f"},
ColorRules -> {x_ -> ColorData["Rainbow"][(x/6)]}]
It indeed looks like a bug but is there any relationship between PlotLegend and ChartLegends? ChartLegends work well in a chart when there's more than 5 of them.
 
Van Ladmon said:
It indeed looks like a bug but is there any relationship between PlotLegend and ChartLegends?
I have no idea. You should submit a bug report to Wolfram.
 

Similar threads

Replies
1
Views
3K
Replies
1
Views
3K
Back
Top