0

I have tried for hours now to find any documentation on this, but it doesn't appear to exist. After battling for days to get any of the methods for creating and showing plots in Django to work, I finally managed to get nvd3 for django working. But now I am having problems with the notations on the y axis of my plot. Because my values are very small (at most 1.0e-4) I want to use scientific notation with exponentials.

The command to do what I want appears to be chart.y1Axis.d3.format(".2f") in d3, but I have no clue how to apply this in nvd3. Does anyone know how to deal implement it?

Also, on the x axis I have the opposite problem that the values are large. Because the plot is log-log the routine puts a ticklabel on 10, 20, 30 40,...100, 200, 300, 400..and so on, but I want it to only plot for every order of magnitude (10, 100, 1000, 10000 etc.). What is the easiest way to automate this? Would it work if I tell the routine to always print the ticks for 10, 100, 1000, 10000, and so on up to an exceedingly high value, even though my plot wouldn't reach as high? How would I do that?

This is how the plot looks like right now:

View of plot

Frank
  • 619
  • 1
  • 6
  • 26

1 Answers1

1

Use this for scientific notations on y axis

 chart.yAxis.tickFormat(d3.format('.02e'));

for x axis problem try this

this will return log for the x values.

chart.x(function(d){return Math.log10(d.x)});

and this will again covert it to normal number, your scale will be logarithmic

chart.xAxis.tickFormat(function(d){ return (Math.pow(10,d)).toFixed(2);});

Here is the JSFiddle

jawadhoot
  • 164
  • 1
  • 7
  • Thank you very much, however I don't actually know where to put this information. I use a different approach it seems since those commands are not accepted, or at least I can't figure out where it should be listed. I have part of my code listed on this question in this [link](http://stackoverflow.com/questions/31637980/django-show-plot-from-sqlite-database-accessed-by-form) I tried using the code you had in JSFiddle, but I know there must be code that is "hidden" so I can't try the example locally. – Frank Jul 29 '15 at 09:09