% Get this figure: fig = getplotlyfig('ggplot2examples', 98) % Get this figure's data: fig = getplotlyfig('ggplot2examples', 98); fig.data % Add data to this figure: plotly([1, 2], [2, 3], struct('filename', 'from api (32)', 'fileopt', 'extend')) % Get y data of first trace: fig = getplotlyfig('ggplot2examples', 98); y1 = fig.data{1}.y % Get figure documentation: https://plotly.com/matlab/get-requests/ % Add data documentation: https://plotly.com/matlab/file-options/ % You can reproduce this figure in MATLAB with the following code! % Learn about API authentication here: https://plotly.com/matlab/getting-started % Find your api_key here: https://plotly.com/settings/api signin('username', 'api_key') trace1 = struct(... 'uid', 'fec647', ... 'line', struct(... 'dash', 'solid', ... 'color', 'rgb(248,118,109)', ... 'shape', 'spline', ... 'width', 3), ... 'mode', 'lines', ... 'name', 'Chile', ... 'text', NaN, ... 'type', 'scatter', ... 'x', [1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012], ... 'y', [NaN, NaN, 600, 640, 660, 650, 740, 760, 770, 800, 860, 1020, 1110, 1320, 1620, 1120, 980, 1070, 1320, 1740, 2240, 2640, 2190, 1780, 1600, 1410, 1410, 1560, 1820, 2090, 2240, 2490, 3020, 3330, 3610, 4320, 4930, 5380, 5250, 4910, 4920, 4760, 4550, 4570, 5230, 6250, 7260, 8630, 10020, 9930, 10720, 12270, 14310], ... 'marker', struct('line', struc)), ... 'error_x', struc), ... 'error_y', struc), ... 'textfont', struc)); trace2 = struct(... 'uid', '10a1c6', ... 'line', struct(... 'dash', 'solid', ... 'color', 'rgb(0,186,56)', ... 'shape', 'spline', ... 'width', 3), ... 'mode', 'lines', ... 'name', 'Hungary', ... 'text', NaN, ... 'type', 'scatter', ... 'x', [1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012], ... 'y', [NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 540, 590, 670, 830, 1000, 1150, 1200, 1330, 1520, 1770, 2070, 2200, 2170, 2010, 1930, 1860, 2040, 2400, 2710, 2770, 2880, 2740, 3140, 3630, 4000, 4220, 4320, 4370, 4380, 4460, 4580, 4720, 5210, 6550, 8540, 10220, 11040, 11510, 12890, 12980, 12930, 12900, 12410], ... 'marker', struct('line', struc)), ... 'error_x', struc), ... 'error_y', struc), ... 'textfont', struc)); trace3 = struct(... 'uid', 'f5a68f', ... 'line', struct(... 'dash', 'solid', ... 'color', 'rgb(97,156,255)', ... 'shape', 'spline', ... 'width', 3), ... 'mode', 'lines', ... 'name', 'Uruguay', ... 'text', NaN, ... 'type', 'scatter', ... 'x', [1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012], ... 'y', [NaN, NaN, 580, 610, 660, 680, 720, 640, 610, 670, 820, 850, 870, 1060, 1370, 1620, 1490, 1420, 1630, 2150, 2870, 3650, 3290, 2190, 1740, 1510, 1780, 2210, 2600, 2730, 2840, 3180, 3830, 4350, 5040, 5530, 6160, 6970, 7240, 7260, 7050, 6500, 5140, 4240, 4130, 4720, 5380, 6380, 7690, 8520, 10110, 11700, 13580], ... 'marker', struct('line', struc)), ... 'error_x', struc), ... 'error_y', struc), ... 'textfont', struc)); data = {trace1, trace2, trace3}; layout = struct(... 'font', struct(... 'size', 12, ... 'color', '#444', ... 'family', '"Open sans", verdana, arial, sans-serif'), ... 'smith', false, ... 'title', 'Click to enter Plot title', ... 'width', 1255, ... 'xaxis', struct(... 'type', 'linear', ... 'dtick', 10, ... 'range', [1960, 2012], ... 'tick0', 0, ... 'ticks', '', ... 'title', 'year', ... 'anchor', 'y', ... 'domain', [0, 1], ... 'mirror', false, ... 'nticks', 0, ... 'ticklen', 5, ... 'autotick', true, ... 'position', 0, ... 'showgrid', true, ... 'showline', false, ... 'tickfont', struct(... 'size', 0, ... 'color', '', ... 'family', ''), ... 'zeroline', false, ... 'autorange', true, ... 'gridcolor', 'rgb(255,255,255)', ... 'gridwidth', 1, ... 'linecolor', '#444', ... 'linewidth', 1, ... 'rangemode', 'normal', ... 'tickangle', 'auto', ... 'tickcolor', 'rgb(127,127,127)', ... 'tickwidth', 1, ... 'titlefont', struct(... 'size', 0, ... 'color', '', ... 'family', ''), ... 'overlaying', false, ... 'showexponent', 'all', ... 'zerolinecolor', '#444', ... 'zerolinewidth', 1, ... 'exponentformat', 'B', ... 'showticklabels', true), ... 'yaxis', struct(... 'type', 'linear', ... 'dtick', 2000, ... 'range', [-225.00000000000023, 15075], ... 'tick0', 0, ... 'ticks', '', ... 'title', 'NY.GNP.PCAP.CD', ... 'anchor', 'x', ... 'domain', [0, 1], ... 'mirror', false, ... 'nticks', 0, ... 'ticklen', 5, ... 'autotick', true, ... 'position', 0, ... 'showgrid', true, ... 'showline', false, ... 'tickfont', struct(... 'size', 0, ... 'color', '', ... 'family', ''), ... 'zeroline', false, ... 'autorange', true, ... 'gridcolor', 'rgb(255,255,255)', ... 'gridwidth', 1, ... 'linecolor', '#444', ... 'linewidth', 1, ... 'rangemode', 'normal', ... 'tickangle', 'auto', ... 'tickcolor', 'rgb(127,127,127)', ... 'tickwidth', 1, ... 'titlefont', struct(... 'size', 0, ... 'color', '', ... 'family', ''), ... 'overlaying', false, ... 'showexponent', 'all', ... 'zerolinecolor', '#444', ... 'zerolinewidth', 1, ... 'exponentformat', 'B', ... 'showticklabels', true), ... 'bargap', 0.2, ... 'boxgap', 0.3, ... 'height', 492, ... 'legend', struct(... 'x', 1.02, ... 'y', 0.5, ... 'font', struct(... 'size', 0, ... 'color', '', ... 'family', ''), ... 'bgcolor', '#fff', ... 'xanchor', 'left', ... 'yanchor', 'auto', ... 'traceorder', 'normal', ... 'bordercolor', 'transparent', ... 'borderwidth', 0), ... 'margin', struct(... 'b', 80, ... 'l', 80, ... 'r', 10, ... 't', 100, ... 'pad', 0, ... 'autoexpand', true), ... 'barmode', 'group', ... 'boxmode', 'overlay', ... 'autosize', true, ... 'dragmode', 'zoom', ... 'hovermode', 'x', ... 'titlefont', struct(... 'size', 0, ... 'color', '', ... 'family', ''), ... 'separators', '.,', ... 'showlegend', true, ... 'bargroupgap', 0, ... 'boxgroupgap', 0.3, ... 'hidesources', false, ... 'plot_bgcolor', 'rgb(229,229,229)', ... 'paper_bgcolor', '#fff'); response = plotly(data, struct('layout', layout)); plot_url = response.url