ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Log scale in decibels
Posted by Russ on Feb-08-2021 21:40
I'm trying to display a frequency spectrum on an XYchart, using the log scale for the Y axis, to represent power.  But the labeling on the chart shows power as a multiple of power value, like (1,10,100...)  But I need it to show power in dB, like (0,10,20,30...).  I tried generating my own label strings and attach them like:

  pChart->yAxis ()->setLogScale (0, yMax), StringArray (ya,10));

I also tried

  pChart->yAxis ()->setLogScale (0, yMax);
  pChart->yAxis ()->setLabels (DoubleArray (dya, 5));

But in both cases the result was no longer logarithmic, and the labels were not even as I specifed, meaning that it tried to interpolate between my labels.

How can I make this work?

Thanks, Russ

  Re: Log scale in decibels
Posted by Peter Kwan on Feb-08-2021 23:06
Hi Russ,

For log scale, the value 0 is invalid. So it should be:

pChart->yAxis ()->setLogScale (1, 1000000000, StringArray(ya,10));

I understand the data are power level, but you want to display decibels. Apart from the custom labels, another method is to convert your data to decibels before passing the data to ChartDirector. In this case, the axis is a linear axis in decibel and the axis unit matches the data unit.

Regards
Peter Kwan

  Re: Log scale in decibels
Posted by Russ on Feb-12-2021 23:56
Thank you Peter. Yes I see now that a dB scale would be linear.  Was thinking wrong.
Regards, Russ