### Install Plotly for MATLAB (Offline) Source: https://github.com/plotly/plotly_matlab/blob/master/README.md Installs the Plotly graphing library for MATLAB in offline mode. Requires downloading the latest version of the wrapper and running the setup function. Optionally accepts a plotly bundle URL. ```MATLAB plotlysetup_offline() % or with a bundle URL: plotlysetup_offline('http://cdn.plot.ly/plotly-latest.min.js') ``` -------------------------------- ### Install Plotly for MATLAB (Online) Source: https://github.com/plotly/plotly_matlab/blob/master/README.md Installs the Plotly graphing library for MATLAB for online use. Requires your Plotly username and API key for authentication. ```MATLAB plotlysetup_online('your_username', 'your_api_key') ``` -------------------------------- ### Configure Plotly for Online Use in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Configures the Plotly library for online usage by saving user credentials and optionally setting up custom domains. This requires a Plotly account and API key for publishing charts to the Plotly cloud. It supports streaming IDs for real-time data and custom Plotly domains for enterprise installations. ```matlab plotlysetup_online('your_username', 'your_api_key'); plotlysetup_online('your_username', 'your_api_key', ... 'stream_ids', {'stream_id_1', 'stream_id_2'}); plotlysetup_online('your_username', 'your_api_key', ... 'plotly_domain', 'https://your-plotly-server.com'); plotlysetup_online('your_username', 'your_api_key', ... 'stream_ids', {'stream_id_1', 'stream_id_2'}, ... 'plotly_domain', 'https://your-plotly-server.com', 'plotly_streaming_domain', 'https://stream.your-plotly-server.com'); ``` -------------------------------- ### Configure Plotly Figures with Comprehensive Options in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Provides comprehensive configuration options for controlling figure behavior and output, including filename, file options, visibility, offline mode, and styling. It also allows access to the figure handle, data validation, and reverting or stripping styles. ```matlab p = plotlyfig(gcf, ... 'filename', 'comprehensive_chart', 'fileopt', 'overwrite', ... % 'new', 'overwrite', 'extend', 'append' 'world_readable', true, ... % Public or private 'offline', true, ... % Offline HTML mode 'open', true, ... % Open in browser after creation 'strip', false, ... % Strip MATLAB styling 'stripmargins', false, ... % Remove margins 'visible', 'on', ... % Figure visibility 'savefolder', pwd, ... % Output directory 'treatas', 'scatter', ... % Force plot type 'axisequal', false, ... % Equal axis scaling 'aspectratio', [1 1 1], ... % Custom aspect ratio 'cameraeye', [1.5 1.5 1.5], ... % 3D camera position 'frameduration', 100, ... % Animation frame duration (ms) 'frametransitionduration', 50); % Animation transition (ms) fig_handle = p.gpf(); p.validate(); clean_data = p.getdata(); p.revert(); p.strip(); ``` -------------------------------- ### Create and Control Plotly Figures with plotlyfig (MATLAB) Source: https://context7.com/plotly/plotly_matlab/llms.txt The `plotlyfig` class in MATLAB provides a foundation for creating and customizing Plotly figures. It allows for fine-grained control over the conversion process, data manipulation, and figure rendering. Users can initialize `plotlyfig` from an existing MATLAB figure or create an empty one to populate manually. ```matlab % Create plotlyfig from current figure p = plotlyfig(gcf); % Create with custom options p = plotlyfig(gcf, \ 'filename', 'my_visualization', \ 'offline', true, \ 'strip', false, \ 'visible', 'on'); % Access and modify data and layout p.data % Cell array of trace data p.layout % Structure containing layout configuration % Update the figure after modifications p.update(); % Send to Plotly p.plotly(); % Create empty plotlyfig and populate manually p = plotlyfig(); p.data = {{struct('x', [1,2,3], 'y', [4,5,6], 'type', 'scatter')}}; p.layout = struct('title', struct('text', 'Manual Chart')); p.plotly(); ``` -------------------------------- ### Download Figure Data into plotlyfig with download (MATLAB) Source: https://context7.com/plotly/plotly_matlab/llms.txt The `download` method of the `plotlyfig` object enables downloading figure data directly from Plotly into an existing `plotlyfig` instance. This is useful for retrieving data to modify and then re-upload. The method takes 'username' and 'figure_id' as arguments. ```matlab % Create empty plotlyfig and download data p = plotlyfig('Visible', 'off'); p.download('username', 'figure_id'); % Work with the downloaded data disp(p.data); disp(p.layout); ``` -------------------------------- ### Sign in to Plotly Session in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Signs in to a Plotly session, managing persistent username, API key, and domain settings. It can also retrieve current credentials without signing in. This function is useful for managing authentication across multiple Plotly operations. ```matlab signin('your_username', 'your_api_key'); signin('your_username', 'your_api_key', 'https://custom-plotly.com'); [username, api_key, domain] = signin(); ``` -------------------------------- ### Apply Visual Themes to Plotly Figures with addtheme (MATLAB) Source: https://context7.com/plotly/plotly_matlab/llms.txt The `addtheme` function applies predefined visual themes to Plotly figures in MATLAB. It accepts a `plotlyfig` object and a theme name as input. A wide range of themes are available, including 'ggplot2', 'plotly_dark', 'seaborn', and 'simple_white', each offering distinct aesthetic styles. ```matlab % Create a figure figure; bar([1 2 3 4], [10 20 15 25]); title('Quarterly Sales'); p = plotlyfig(gcf); % Apply ggplot2 theme p = addtheme(p, 'ggplot2'); p.plotly(); % Apply dark theme for presentations p = addtheme(p, 'plotly_dark'); p.plotly(); % Apply seaborn theme (data science style) p = addtheme(p, 'seaborn'); p.plotly(); % Apply simple white theme for publications p = addtheme(p, 'simple_white'); p.plotly(); % Available themes: % - ggplot2 : R ggplot2 style % - plotly : Default Plotly style % - plotly_dark : Dark mode % - plotly_white : White background % - seaborn : Seaborn (Python) style % - simple_white : Minimalist white % - presentation : Larger fonts for slides % - gridon : Grid lines enabled % - xgridoff : X grid lines disabled % - ygridoff : Y grid lines disabled ``` -------------------------------- ### Save Plotly Credentials in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Saves Plotly authentication credentials (username, API key, and optionally streaming IDs) to the local filesystem for persistent access across MATLAB sessions. The credentials are stored as JSON in the `~/.plotly/.credentials` file. ```matlab saveplotlycredentials('your_username', 'your_api_key'); saveplotlycredentials('your_username', 'your_api_key', {'stream_id_1', 'stream_id_2', 'stream_id_3'}); ``` -------------------------------- ### Convert MATLAB Heatmaps to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB heatmaps and imagesc plots to Plotly format using `fig2plotly()`. This enables interactive visualization of matrix data with color mapping. ```matlab % Heatmaps heatmap(matrix); imagesc(matrix); p = fig2plotly(); ``` -------------------------------- ### Configure Plotly for Offline Use in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Sets up the Plotly library for offline usage by adding it to the MATLAB path and downloading necessary JavaScript dependencies. This is ideal for generating standalone HTML files without needing a Plotly account. It supports using the default Plotly.js CDN or a custom URL. ```matlab plotlysetup_offline(); plotlysetup_offline('http://cdn.plot.ly/plotly-latest.min.js'); ``` -------------------------------- ### Retrieve Plotly Figure Source: https://github.com/plotly/plotly_matlab/blob/master/README.md Downloads Plotly figure data from the Plotly online service. Requires the username and figure ID of the desired graph. ```MATLAB p = getplotlyfig('chris', 1638) % downloads the graph data from https://plot.ly/~chris/1638 ``` -------------------------------- ### Retrieve Plotly Figures with getplotlyfig (MATLAB) Source: https://context7.com/plotly/plotly_matlab/llms.txt The `getplotlyfig` function allows users to download existing Plotly figures from the cloud by providing the owner's username and the figure ID. It returns a `plotlyfig` object containing the chart's data and layout, which can then be modified and re-uploaded or exported as an image. ```matlab % Download a public figure % URL: https://plot.ly/~demos/1526 p = getplotlyfig('demos', '1526'); % Access the downloaded data data = p.data; layout = p.layout; % Modify and re-upload p.layout.title.text = 'Modified Chart Title'; p.PlotOptions.FileName = 'my_modified_chart'; p.plotly(); % Download and export as image p = getplotlyfig('chris', '1638'); p.saveas('downloaded_chart', 'png'); ``` -------------------------------- ### Generate Offline HTML Charts with Plotly MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Creates standalone HTML files with embedded Plotly.js for sharing interactive charts without a Plotly account. Configure save location and whether to embed the Plotly.js library directly in the HTML. ```matlab p = plotlyfig(gcf, 'offline', true); p.PlotOptions.SaveFolder = '/path/to/output'; p.PlotOptions.FileName = 'interactive_chart'; p.PlotOptions.IncludePlotlyjs = true; % Embed JS in HTML p.PlotOptions.IncludePlotlyjs = false; % Use CDN reference p.plotly(); % Output: /path/to/output/interactive_chart.html ``` -------------------------------- ### Convert MATLAB Box Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB box plots to Plotly format using `fig2plotly()`. This enables interactive visualization of data distributions and summary statistics. ```matlab % Box plots boxplot(data); p = fig2plotly(); ``` -------------------------------- ### Convert MATLAB Stem Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB stem plots to Plotly format using `fig2plotly()`. This enables interactive visualization of discrete data points with stems. ```matlab % Stem plots stem(x, y); p = fig2plotly(); ``` -------------------------------- ### Convert MATLAB Histograms to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB histograms, including 1D and 2D versions, to Plotly format using `fig2plotly()`. This allows for interactive exploration of data distributions. ```matlab % Histograms histogram(data); histogram2(x, y); p = fig2plotly(); ``` -------------------------------- ### Convert MATLAB Quiver Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB quiver plots (vector fields) to Plotly format using `fig2plotly()`. This allows for interactive visualization of vector data. ```matlab % Quiver plots (vector fields) quiver(X, Y, U, V); p = fig2plotly(); ``` -------------------------------- ### Generate Static Images with plotlygenimage (MATLAB) Source: https://context7.com/plotly/plotly_matlab/llms.txt The `plotlygenimage` function generates static images of Plotly figures using the Plotly REST API. This method requires authentication and sends figure data to Plotly's servers for rendering. It supports generating images in PNG, SVG, and PDF formats, allowing users to specify the output filename and format. ```matlab % Create figure data structure figure_data = struct(); figure_data.data = {{struct('x', [1,2,3,4], 'y', [10,15,13,17], 'type', 'scatter')}}; figure_data.layout = struct('title', struct('text', 'Sales Data')); % Generate PNG image plotlygenimage(figure_data, 'sales_chart.png'); % Generate SVG for vector graphics plotlygenimage(figure_data, 'sales_chart.svg', 'svg'); % Generate PDF for documents plotlygenimage(figure_data, 'sales_chart.pdf', 'pdf'); ``` -------------------------------- ### Convert MATLAB Stairs Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB stairs plots to Plotly format using `fig2plotly()`. This allows for interactive visualization of data represented as step functions. ```matlab % Stairs plots stairs(x, y); p = fig2plotly(); ``` -------------------------------- ### Convert MATLAB Geographic Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB geographic plots (requires Mapping Toolbox) to Plotly format using `fig2plotly()`. This enables interactive visualization of geospatial data. ```matlab % Geographic plots (requires Mapping Toolbox) geoplot(lat, lon); geoscatter(lat, lon); p = fig2plotly(); ``` -------------------------------- ### Convert MATLAB Area Charts to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts standard MATLAB area plots to Plotly format using `fig2plotly()`. This enables interactive visualization of cumulative data or trends over time. ```matlab % Area charts area(x, y); p = fig2plotly(); ``` -------------------------------- ### Add Custom Annotations to Plotly Figures in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Adds custom text annotations and captions to Plotly figures with full positioning control. Captions can be added below the chart or with specific coordinates and anchors for precise placement. ```matlab figure; plot(1:10, rand(1,10)); p = plotlyfig(gcf); p.add_caption('Source: Random data generator'); p.add_caption('Note: Values are normalized', ... 'x', 0.5, ... 'y', -0.1, ... 'xanchor', 'center', ... 'yanchor', 'top'); p.plotly(); ``` -------------------------------- ### Convert MATLAB Figures to Plotly Charts Source: https://context7.com/plotly/plotly_matlab/llms.txt The primary function for converting MATLAB figures into interactive Plotly graphs. It accepts a figure handle and various options to either upload the chart to Plotly's cloud or generate an offline HTML file. The function returns a structure containing information about the generated plot, including its URL. ```matlab x = 0:0.01:20; y1 = 200*exp(-0.05*x).*sin(x); y2 = 0.8*exp(-0.5*x).*sin(10*x); figure; [ax, h1, h2] = plotyy(x, y1, x, y2, 'plot'); xlabel('Time (s)'); title('Frequency Response'); ax(1).YLabel.String = "Low Frequency"; ax(2).YLabel.String = "High Frequency"; p = fig2plotly(); fig = figure; plot(rand(10,3)); p = fig2plotly(fig); p = fig2plotly(gcf, 'filename', 'my_chart'); p = fig2plotly(gcf, ... 'filename', 'frequency_response', 'fileopt', 'overwrite', 'world_readable', true, 'open', true, 'offline', true); disp(p.url); ``` -------------------------------- ### Convert MATLAB Scatter Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts standard MATLAB scatter plots, including those with size and color variations, to Plotly format using `fig2plotly()`. This allows for interactive exploration of scatter data. ```matlab % Scatter plots scatter(x, y, sizes, colors); p = fig2plotly(); ``` -------------------------------- ### Convert MATLAB 3D Surface Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB 3D surface plots, including mesh and surface with contour variations, to Plotly format using `fig2plotly()`. This enables interactive exploration of 3D data. ```matlab % 3D Surface plots surf(X, Y, Z); mesh(X, Y, Z); surfc(X, Y, Z); % Surface with contour p = fig2plotly(); ``` -------------------------------- ### Save Plotly Figures as Static Images using saveas (MATLAB) Source: https://context7.com/plotly/plotly_matlab/llms.txt The `saveas` method of the `plotlyfig` object allows users to save Plotly figures as static image files. It supports various formats like PNG, PDF, SVG, and JPEG by leveraging the Plotly image generation API. Shorthand methods like `png`, `pdf`, `svg`, and `jpeg` are also available for convenience. ```matlab % Create and convert figure x = linspace(0, 2*pi, 100); y = sin(x); plot(x, y); title('Sine Wave'); p = plotlyfig(gcf); % Save as different formats p.saveas('sine_wave', 'png'); p.saveas('sine_wave', 'pdf'); p.saveas('sine_wave', 'svg'); p.saveas('sine_wave', 'jpeg'); % Shorthand methods p.png('sine_wave'); p.pdf('sine_wave'); p.svg('sine_wave'); p.jpeg('sine_wave'); ``` -------------------------------- ### Convert MATLAB Polar Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB polar plots, including histograms, to Plotly format using `fig2plotly()`. This allows for interactive visualization of data in polar coordinates. ```matlab % Polar plots polarplot(theta, rho); polarhistogram(theta); p = fig2plotly(); ``` -------------------------------- ### Save Plotly Figure as Image Source: https://github.com/plotly/plotly_matlab/blob/master/README.md Exports a Plotly figure object to a specified image file format. Supports formats like SVG for publication-quality images. ```MATLAB saveplotlyfig(p, 'testimage.svg') ``` -------------------------------- ### Convert MATLAB Line Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts standard MATLAB line plots to Plotly format using the `fig2plotly()` function. This enables interactive visualization of line data within the Plotly ecosystem. ```matlab % Line plots plot(x, y); p = fig2plotly(); ``` -------------------------------- ### Export Plotly Figures with write_image (MATLAB) Source: https://context7.com/plotly/plotly_matlab/llms.txt The `write_image` function exports Plotly figures to static images using the Kaleido rendering engine. This function offers high-quality image generation with options to specify format, filename, dimensions (width and height), and scaling factor. It's suitable for generating various image types including PNG, SVG, and PDF. ```matlab % Create a plotlyfig object figure; surf(peaks); p = plotlyfig(gcf); % Export with default settings (PNG) write_image(p); % Export with custom format and filename write_image(p, 'imageFormat', 'svg', 'filename', 'peaks_surface.svg'); % Export with custom dimensions write_image(p, \ 'imageFormat', 'png', \ 'filename', 'peaks_large.png', \ 'width', 1920, \ 'height', 1080, \ 'scale', 2); % Export to PDF write_image(p, 'imageFormat', 'pdf', 'filename', 'peaks_report.pdf'); ``` -------------------------------- ### Convert MATLAB Bar Charts to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts various MATLAB bar chart types, including horizontal and 3D bars, to Plotly format using `fig2plotly()`. This facilitates interactive visualization of categorical data. ```matlab % Bar charts bar(categories, values); barh(categories, values); % Horizontal bar3(matrix); % 3D bars p = fig2plotly(); ``` -------------------------------- ### Convert MATLAB Contour Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB contour plots, including filled and 3D versions, to Plotly format using `fig2plotly()`. This allows for interactive visualization of scalar field data. ```matlab % Contour plots contour(X, Y, Z); contourf(X, Y, Z); % Filled contour3(X, Y, Z); % 3D p = fig2plotly(); ``` -------------------------------- ### Convert MATLAB Figure to Plotly Graph Source: https://github.com/plotly/plotly_matlab/blob/master/README.md Converts the current MATLAB figure into an interactive Plotly graph. This function is the core of the library's usage for online visualization. ```MATLAB % Create some data for the two curves to be plotted x = 0:0.01:20; y1 = 200*exp(-0.05*x).*sin(x); y2 = 0.8*exp(-0.5*x).*sin(10*x); % Create a plot with 2 y axes using the plotyy function figure; [ax, h1, h2] = plotyy(x, y1, x, y2, 'plot'); % Add title and x axis label xlabel('Time (s)'); title('Frequency Response'); % Use the axis handles to set the labels of the y axes ax(1).YLabel.String = "Low Frequency"; ax(2).YLabel.String = "High Frequency"; %--PLOTLY--% p = fig2plotly; % <-- converts the yy-plot to an interactive, online version. %--URL--% % p.url = 'https://plot.ly/~matlab_user_guide/1522' ``` -------------------------------- ### Convert MATLAB Error Bar Plots to Plotly in MATLAB Source: https://context7.com/plotly/plotly_matlab/llms.txt Converts MATLAB error bar plots to Plotly format using `fig2plotly()`. This allows for interactive visualization of data with associated uncertainties. ```matlab % Error bars errorbar(x, y, err); p = fig2plotly(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.