
Custom tick labels
This discussion was imported from CodePlex
danielmda wrote at 2013-08-08 07:42:
Hello.
I need to plot some numeric data as a function of audio frequency. The frequency axis (x axis) is in octave bands - which is base 2 log. Here's an example I found online of what I want to plot:

(reference: http://www.dpamicrophones.com/da/MikrofonUniversitet/Tech-Guide/Acoustics.aspx)
The picture is not very good quality, the frequency values are: 63, 125, 250, 500, 1k, 2k, 4k, 8k Hz.
I can't seem to be able to create such an axis. I've tried a few things without success:
I need to plot some numeric data as a function of audio frequency. The frequency axis (x axis) is in octave bands - which is base 2 log. Here's an example I found online of what I want to plot:

(reference: http://www.dpamicrophones.com/da/MikrofonUniversitet/Tech-Guide/Acoustics.aspx)
The picture is not very good quality, the frequency values are: 63, 125, 250, 500, 1k, 2k, 4k, 8k Hz.
I can't seem to be able to create such an axis. I've tried a few things without success:
- Using log axis for frequency - but the values are calculated with a reference of 1. That means values count up as so: 1, 2, 4, 8, 16... etc. I need a way to set a custom reference (e.g. 1000 Hz) so I can start at 63 (or 62.5) and work my way up from there.
- Using a category axis for frequency, so I can specify a custom string - but I need the labels to line up with the grid lines, not in between the grid lines (if that makes sense?)
- Using a linear axis for frequency - but I see no way of replacing the numeric labels with custom strings.
WeirdNoise wrote at 2013-08-11 17:59:
You could just override the LogarithmicAxis.GetTickValues() without recompiling oxyplot as I did
here.
A hacky, but nonetheless working, example (in VB I'm afraid):
A hacky, but nonetheless working, example (in VB I'm afraid):
Public Class MyLogAxis
Inherits Axes.LogarithmicAxis
Public Overrides Sub GetTickValues(ByRef majorLabelValues As IList(Of Double), ByRef majorTickValues As IList(Of Double), ByRef minorTickValues As IList(Of Double))
majorTickValues = New List(Of Double)
majorTickValues.Add(63)
majorTickValues.Add(125)
majorTickValues.Add(250)
majorTickValues.Add(500)
majorTickValues.Add(1000)
majorTickValues.Add(2000)
majorTickValues.Add(4000)
majorTickValues.Add(8000)
minorTickValues = majorTickValues
majorLabelValues = majorTickValues
End Sub
End Class
danielmda wrote at 2013-08-13 09:00:
Ah, that's awesome. Thank you so much!
Customer support service by UserEcho
I'm looking to customize it further (templating would be a great option). I need to turn the tick marks into buttons with their respective values as the buttons text. Is this possible?