I am trying to create some functions that will avoid me to repeat plot options for different types of plot. I encounter some troubles as I try to create mechanisms to automatically handle Frameticks & Plot Range given the data considered within a given plot.
Module[{chartData},
chartData = RandomInteger[20, 20];
BarChart[chartData,
Frame -> {{True, True}, {True, True}},
ImageSize -> 300,
ChartStyle -> Black,
FrameLabel -> {{"yName", None}, {None, "xName"}},
ChartElementFunction -> "FadingRectangle",
LabelStyle -> Directive[Black, Bold, 18],
PlotRange -> {Automatic, 1.3*Max@chartData},
FrameTicks -> {{{Round@Min@chartData, Round@(Max@chartData/2),
Round@Max@chartData}, None},
{{0, Round@(Length@chartData/2), Length@chartData}, None}}
]]
Now Here is my attempt to simplify my life :
chartOptions[yName_, xName_] := {Frame -> {{True, True}, {True, True}},
ImageSize -> 300,
ChartStyle -> Blue,
FrameLabel -> {{yName, None}, {None, xName}},
ChartElementFunction -> "FadingRectangle",
LabelStyle -> Directive[Black, Bold, 18],
FrameTicks -> {{{Round@Min@chartData, Round@(Max@chartData/2),
Round@Max@chartData}, None},
{{0,Round@(Length@chartData/2),
Length@chartData}, None}},
PlotRange -> {Automatic, 1.3*Max@chartData}}
This so that hopefully my actual Chart code is as such :
Module[{chartData},
chartData = RandomInteger[20, 20];
BarChart[chartData,
chartOptions["yName", "xName"]]]
But this does not work :
The idea is that the chartOptions function will be adjusted given the chart data of the actual plot where it is used.
I am now trying to only use things I trully understand so I hope such a problem does not require to much of your sophisticated skills :-) !