![add second axis matlab 2012 add second axis matlab 2012](https://i.pinimg.com/originals/93/53/99/935399e08bca5e0282818fffcc223e0a.png)
HRuler.Label.> x = linspace ( - 2 * pi, 2 * pi ) > y1 = sin ( x ) > y2 = cos ( x ) > plot ( x, y1, x, y2 ) %% Translate the figure from MATLAB to Plotly > fig = plotlyfig ( gcf ) > fig. NewTicks = strsplit(sprintf(formatString, ), '\n') The type of ruler that MATLAB creates for each axis depends on the plotted data. Modify the appearance and behavior of a particular axis by accessing the associated ruler and setting ruler properties. % Compute tick values for new axis scale:ĭiff(newLimits).*(tickValues-limits(1))./diff(limits) įormatString = ['\' tickColor hRuler.TickLabelFormat ' The ruler controls the appearance and behavior of the x -axis, y -axis, or z -axis. 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) The additional set of tick (and axis) labels can be colored using TeX markup to differentiate them.
#Add second axis matlab 2012 code#
I wrapped some code into a prototype function that does this. 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. 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.
![add second axis matlab 2012 add second axis matlab 2012](http://3.bp.blogspot.com/-eHNCYAhgSxg/TyJAw1XHIjI/AAAAAAAACpQ/iPO09D3EhYo/s320/image004-767851.jpg)
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)
![add second axis matlab 2012 add second axis matlab 2012](https://i.ytimg.com/vi/1XiIZczRyAQ/maxresdefault.jpg)
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.
![add second axis matlab 2012 add second axis matlab 2012](http://www.wikihow.com/images/d/d5/Add-a-Second-Y-Axis-to-a-Graph-in-Microsoft-Excel-Step-8-Version-2.jpg)
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).