How to add legends with 6 or more discrete entries?

  • Mathematica
  • Thread starter Van Ladmon
  • Start date
  • Tags
    Discrete
In summary, the conversation discusses a potential bug in the use of legends in ArrayPlot. The user's code works well for the first 5 graphs, but after the 6th graph, the legends become strange and stick together. The user wonders if there is a maximum number of elements in a legend and if there is a relationship between PlotLegend and ChartLegends. It is suggested to submit a bug report to Wolfram if the issue persists.
  • #1
Van Ladmon
8
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
  • #2
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)]}]
 
  • #3
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.
 
  • #4
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.
 

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

1. How do I add a legend with 6 or more discrete entries?

To add a legend with 6 or more discrete entries, you can use the legend() function in your coding language, such as Python or R. This function will allow you to specify the labels and colors for each entry in your legend.

2. Can I customize the legend entries to match my data?

Yes, you can customize the legend entries to match your data by using the label and color parameters in the legend() function. You can also adjust the font size, style, and placement of the legend to better fit your data.

3. How can I add a title to my legend?

To add a title to your legend, you can use the title argument in the legend() function. This will allow you to specify the text and format of the title, such as font size and color.

4. Is it possible to add a legend to a pie chart with 6 or more slices?

Yes, you can add a legend to a pie chart with 6 or more slices by using the legend() function and specifying the corresponding labels and colors for each slice. You can also customize the format and placement of the legend on the pie chart.

5. Can I add symbols or markers to my legend entries?

Yes, you can add symbols or markers to your legend entries by using the marker argument in the legend() function. This will allow you to choose from a variety of shapes and sizes for your legend markers.

Similar threads

  • DIY Projects
Replies
12
Views
289
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
316
Replies
9
Views
3K
  • Math Proof Training and Practice
2
Replies
67
Views
10K
  • Introductory Physics Homework Help
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Replies
13
Views
9K
Back
Top