Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

x-axis label in Flot

Tags:

flot

All I'm trying to do is label my x-axis:

function doPlot(position) {//Flot
  $.plot("#placeholder", [//data
    {
      data: theta_plot,
      label: "Angle (rad)",
      yaxis: 1,
      color: "red"
    },
    {
      data: omega_plot,
      label: "Angular Velocity (rad/sec)",
      yaxis: 2,
      color: "green"
    },
    {
      data: e_plot,
      label: "Energy (J)",
      yaxis: 3,
      color: "blue"
    }
  ],//options
    {
      xaxis: {
        axisLabel: "Time (sec)",
        axisLabelUseCanvas: true
      },
      yaxes: [
        { font: { color: "red" } },
        { font: { color: "green" } },
        { font: { color: "blue" } },
        { alignTicksWithAxis: position === "left" ? 1 : null }
      ],
      legend: {
        position: "nw",
        labelBoxBorderColor: null
      }
    }
    );
}
doPlot("left");

I don't understand why this doesn't work. This should be a no-brainer. All I could come up with is this, which is two years old. Do I still need the jquery.flot.axislabels.js library even now?

Here is a current draft of the plot in question. Any ideas?

like image 983
Joel DeWitt Avatar asked Jan 09 '23 22:01

Joel DeWitt


1 Answers

Do I still need the jquery.flot.axislabels.js library even now?

Yes.

Simple as that, standard Flot has no axis label feature without plugin.

like image 174
Raidri Avatar answered Jan 21 '23 11:01

Raidri