MinValue = Application.Min(CheckRange) - 10 MaxValue = Application.Max(CheckRange) + 10 Set CheckRange = Range(WS.Cells(StartRow, 2), WS.Cells(LastRow, 2)) If (LastRow > 10) Then 'changed as formula = to lastrow 'Check number of rows to graph assumes data row starts at row 6
LastRow = WS.Range("A10").End(xlDown).Row Sub UpdateGraph(ByVal SourceDataSheet As String, ByVal ChartSheet As String, _īyVal ChartName As String, ByVal RowsToGraph As Integer)ĭim MinValue As Double, MaxValue As Double column C and D, with a min value of 0,01 and max value of 1,25.
have a VBA code, see below, that generate a chart with 3 lines. However I want to include a secondary vertical axis for series 2 and 3, i.e. NewTicks = strsplit(sprintf(formatString, ), '\n') % Compute tick values for new axis scale:ĭiff(newLimits).*(tickValues-limits(1))./diff(limits) įormatString = ['\' tickColor hRuler.TickLabelFormat ' The inputs are the axes handle, a string ( 'X', 'Y', or 'Z') for the axes to modify, a new set of axis limits for the new scale (which will be mapped to the current limits), the color of the new labels (as an RGB triple), and a string for the new axis label: function add_scale(hAxes, axisStr, newLimits, newColor, newLabel)
I wrapped some code into a prototype function that does this. The additional set of tick (and axis) labels can be colored using TeX markup to differentiate them. Instead of adding another axis line, a more compact solution that doesn't depend on undocumented features would be to piggyback on an existing axis' tick marks and simply add an additional set of tick labels at a new scale. rotation, zooming, changing limits, etc). However, this could be somewhat cluttered, and I have yet to find a robust way to do this that plays well with changes in the plot (i.e. Achieving an effect where the axes are stacked up on one side, as the answers to this question illustrate, would be more desirable in 3D. on the opposite side) would cause it to be occluded by the plot and not be very useful. Additionally, adding an extra x or y axis in the same fashion (i.e. This has a few drawbacks, the obvious being that undocumented features have a tendency to change without notice. You would need to add some methods that link the two axes together in order to take care of that.Īs illustrated in the answer from Dennis, you could make use of some undocumented features to add an extra axis. Note that this basic example breaks down when you start rotating the axes manually, or zooming in or out. Hb.ZAxis.SecondCrossoverValue = 1 % y-location of z-ruler Hb.ZAxis.FirstCrossoverValue = 1 % x-location of z-ruler % Move z-ruler to opposite corner (from undocumentedmatlab) Hb.Color = 'none' % Transparent background % Hide secondary background and x and y rulers
% Secondary axes on top of primary, using same view point % Primary axes with some arbitrary viewpoint and labels
This is for the z-axis, but the same approach can be used for y or x. The basic idea is illustrated in the example below. Using the FirstCrossOverValue and SecondCrossoverValue properties of the Axes' NumericRuler objects ( XAxis, YAxis, ZAxis), we can position the secondary axis in the desired location. This is explained in the Matlab documentation here.įor 3D this is a bit tricky because of the default axis and label locations, but that's where undocumentedmatlab comes to the rescue. by hiding unused axes and making the secondary background transparent. The idea is that you place a second set of axes on top of the first, then tweak it to fit your requirements, e.g. Not sure if this is what you are looking for, but I guess a basic approach to adding secondary axes to a 3D plot would be the same as for 2D (as far as I know a 2D plot in matlab is just a 3D-plot viewed from above).