This function allows to use two different y-axes with the same data in one plot. Note, that only one curve but in two different units is shown. This is the difference to plotyy which plots two different datasets into one figure.
Take a look to the screenshot and run the different examples in the zip-file to understand the usage.
Thank you for the useful script! Is it possible to control the position of the the second y-axis label, and move it closer to the y-axis? Its position changes each time the numbers on the axis change.
does kill data cursor, but otherwise works great.
Hi Friedhelm, thanks for all the function updates. I really appreciate your responsiveness & openness. I wanted to let you know about a new possible issue. After the chart is rendered, the user should be able to select a plotted point & add an annotation using the Data Cursor tool, right? This isn't working for me after I run the addaxis_unit function. Could you please take a look? Thanks, Brad
Answer to Brad Stiritz: Thanks for this remark. In the newest version (date 2/6/2010), the string format of the ticks for the second y-axis can be controlled by using the optional fifth argument when calling the function addaxis_unit.
Hi Friedhelm, thank you for updating the function per my previous request. I was hoping to be able to control the string formatting when the 'y1' ticks2unit option is specified. It appears that the formatting could be specified by modifying the num2str() calls in lines 146 & 175, a la:
This hack works as long as the figure is *not* resized. For some reason, my modification fails during resizing with the error:
??? Error using ==> set
Invalid parameter/value pair arguments
Error in ==> addaxis_unit>addaxis_unit_resizefcn at 175
??? Error while evaluating figure ResizeFcn
Any help or suggestions appreciated. Thank you again. ~Brad
Answer to Brad Stirlitz: I updated the function, allowing to use the same ticks as on the first y-axis.
Hi Friedhelm, great idea for a utility function! I have a slightly different use-case than the example you provided. In my case, I would like to have different units on the right-side axis, but I would like the right-side axis ticks to match up exactly with the left-side axis ticks. For example, let's say my left-axis tick labels are the values (1:10) and I would like to see what the log of those values are on the opposite axis. Would it be possible to achieve this using your function? Thanks, Brad
Answer to Claudio Gelmi: plotyy plots two datasets into one figure. This function here plots one dataset with two different units.
What is the difference with plotyy?
The string format of the ticks of the second y-axis can be adjusted.
If second y-axis uses the same ticks as the first y-axis, the labels are calculated every time the figure is resized.
Now allows to use the same ticks as first y-axis. This is asked for by Brad Stiritz (16/03/2010).
added support for subplots
updated the description
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.