TransWikia.com

Changing LabelingFunction Color

Mathematica Asked by John Swartz on May 3, 2021

Want to set point text label colors to match actual points. Should be obvious but…

Workaround is to change ALL label coloring but this is not desired. Would like to have black axis labels.

Also should be able to do this without combining plots with Show but I cannot determine the syntax.

rawfiber705 = {{145.1, 40.2}, {150, 33.4}, {148.7, 42.3}, {145, 39.9}, {142, 29.9},  {142.5, 37.9}}
rawfiber390 = {  {146.6, 35.1},  {150.9, 28.2},  {152.4, 36.8},  {146.6, 35.3},  {141.3, 25.5},  {147, 32.2}}

SetOptions[ListPlot, GridLines -> Automatic, Frame -> True,  PlotRange -> All, PlotStyle -> Thick,  BaseStyle -> {FontFamily -> "Gill Sans MT", FontSize -> 14}, LabelStyle -> Directive[Red, Bold], ImageSize -> 500];
ListPlot[(# - rawfiber705[[1]]) & /@ rawfiber705 -> {"0", "Pcw", "Pccw", "0", "Rcw", "Rccw"}, PlotStyle -> Red]

SetOptions[ListPlot, GridLines -> Automatic, Frame -> True, PlotRange -> All, PlotStyle -> Thick, BaseStyle -> {FontFamily -> "Gill Sans MT", FontSize -> 14}, LabelStyle -> Directive[Blue, Bold], ImageSize -> 500];
ListPlot[(# - rawfiber390[[1]]) & /@ rawfiber390 -> {"0", "Pcw", "Pccw", "0", "Rcw", "Rccw"}, PlotStyle -> Blue]

Show[%,%%]

2 Answers

rawfiber705 = {{145.1, 40.2}, {150, 33.4}, {148.7, 42.3}, {145, 
    39.9}, {142, 29.9}, {142.5, 37.9}};
rawfiber390 = {{146.6, 35.1}, {150.9, 28.2}, {152.4, 36.8}, {146.6, 
    35.3}, {141.3, 25.5}, {147, 32.2}};

SetOptions[ListPlot, GridLines -> Automatic, Frame -> True, 
  PlotRange -> All, PlotStyle -> Thick, 
  BaseStyle -> {FontFamily -> "Gill Sans MT", FontSize -> 14}, 
  ImageSize -> 500];

labels = {"0", "Pcw", "Pccw", "0", "Rcw", "Rccw"};

ListPlot[{
  (# - rawfiber705[[1]]) & /@ 
    rawfiber705 -> (Style[#, Red, Bold] & /@ labels),
  (# - rawfiber390[[1]]) & /@ 
    rawfiber390 -> (Style[#, Blue, Bold] & /@ labels)},
 PlotStyle -> {Red, Blue}]

enter image description here

Answered by Bob Hanlon on May 3, 2021

Also

data1 = (# - rawfiber705[[1]]) & /@ rawfiber705;
data2 = (# - rawfiber390[[1]]) & /@ rawfiber390;
styles = {Red, Blue};
labeleddata = Join@@(Thread /@ Thread[{{data1, data2}, Thread[{labels, #}] & /@ styles}]);
newdata = Callout[Style[#, #2[[2]]], Style @@ #2] & @@@ labeleddata;
options = {GridLines -> Automatic, Frame -> True, PlotRange -> All,  PlotStyle -> Thick, 
 BaseStyle -> {FontFamily -> "Gill Sans MT",  FontSize -> 14}, ImageSize -> 500};

ListPlot[newdata, options]

enter image description here

Answered by kglr on May 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP