from
m2googlechart
by Adam Leadbetter
Demonstrates acessing a Java class from Matlab in order to generate Google Chart API plots.
|
| m2googlechart.m |
%A Matlab script to demonstrate plotting a Google line chart from X,Y data
%
% Adam Leadbetter (alead@bodc.ac.uk)
% 17th April 2009
clear all;
clc;
echo on;
% Edit it this to the location where you have saved the
% googleChartBean.class file
javaaddpath c:\BlueJ\webPlots\;
% Set-up some X-data
xData = [1:1:100]';
% Set-up some Y-data
yData = rand(100,2) * 10;
% Set all of the parameters to get the plot...
plotBean = javaObject('googleChartBean'); % Instantiate the object
plotBean.setWinH(500); % Set the plot height (pixels)
plotBean.setWinW(600); % Set the plot width (pixels)
plotBean.setXData(xData); % Set the x-axis data
plotBean.setYData(yData); % Set the y-axis data
plotBean.setXText('X-axis Text'); % Set the x-axis label
plotBean.setYText('Y-axis Text'); % Set the y-axis label
plotBean.setTitleText('Foo'); % Set the plot title
plotBean.setLabelText({'Bar1','Bar2'}); % Set the legend text
% ... and do the line plot
plotString = plotBean.doPlot();
plotString = char(plotString)
echo off;
|
|
Contact us at files@mathworks.com