### Create New Project with op.new() Source: https://context7.com/originlab/originpro/llms.txt Starts a new Origin project. Use `asksave=True` to prompt for saving the current project. ```python import originpro as op # Start a new project without save prompt op.new() ``` ```python # Start a new project with save prompt op.new(asksave=True) ``` -------------------------------- ### Get Origin Paths with op.path() Source: https://context7.com/originlab/originpro/llms.txt Retrieves pre-defined Origin paths for common locations like user files, executable folder, project folder, learning center, and attached files. ```python import originpro as op # Get User Files folder user_folder = op.path('u') # Default # Get Origin Exe folder exe_folder = op.path('e') # Get project folder project_folder = op.path('p') # Get Learning Center folder learning_center = op.path('c') # Get attached file folder attached_folder = op.path('a') ``` ```python # Example: Open sample project op.open(op.path('c') + r'Graphing\Trellis Plots - Box Charts.opju') ``` -------------------------------- ### Get Worksheet Data as DataFrame Source: https://context7.com/originlab/originpro/llms.txt Retrieve all or a portion of worksheet data as a pandas DataFrame using `to_df`. Options include specifying the starting column, number of columns, DataFrame index column, and header row. ```python df = wks.to_df() ``` ```python df = wks.to_df(c1=2) ``` ```python df = wks.to_df(c1='B', numcols=3) ``` ```python df = wks.to_df(c1='B', numcols=2, cindex='A') ``` ```python df = wks.to_df(head='Tag') ``` -------------------------------- ### Exchange Image Data with NumPy Array Source: https://context7.com/originlab/originpro/llms.txt Transfers image data between an image window and a NumPy array. Use `setup` to configure image properties before loading from NumPy. ```python import originpro as op import numpy as np # Set image from NumPy array im = op.new_image() data = np.random.rand(100, 100, 3) # 100x100 RGB image im.setup(3, False, 0) # 3 channels, not multiframe, float64 im.from_np(data) # Get image as NumPy array im = op.find_image('Image1') arr = im.to_np() # Process image arr_flipped = np.flip(arr, 1) im.from_np(arr_flipped) ``` -------------------------------- ### MSheet.xymap - Set Matrix XY Mapping Source: https://context7.com/originlab/originpro/llms.txt Sets or gets the XY coordinate mapping for a matrix sheet. ```APIDOC ## MSheet.xymap ### Description Sets or gets matrix XY coordinate mapping. ### Method Property Access ### Parameters - **xymap** (tuple) - Required - A tuple of (x1, x2, y1, y2) representing the coordinate boundaries. ### Request Example ```python # Set XY mapping ms.xymap = (0, 100, 0, 50) ``` ### Response - **xymap** (tuple) - Returns the current (x1, x2, y1, y2) mapping. ``` -------------------------------- ### Batch Set/Get Column Labels Source: https://context7.com/originlab/originpro/llms.txt Efficiently set or get labels for multiple columns simultaneously using `set_labels` and `get_labels`. Specify the label type ('L', 'U', 'C', etc.). ```python wks.set_labels(['Time', 'Voltage', 'Current'], 'L') ``` ```python wks.set_labels(['s', 'mV', 'mA'], 'U') ``` ```python comments = wks.get_labels('C') ``` -------------------------------- ### Get Matrix Data as NumPy Array Source: https://context7.com/originlab/originpro/llms.txt Retrieves matrix data as a NumPy array, either as a single 2D object or all objects as a 3D array. Supports different dimension orders. ```python import originpro as op import numpy as np ms = op.find_sheet('m') # Get single matrix object as 2D array arr = ms.to_np2d(0) # First matrix object # Get all matrix objects as 3D array arr3d = ms.to_np3d() # Get with different dimension order arr3d = ms.to_np3d(dstack=True) # Process and set back arr = ms.to_np2d(0) arr *= 10 ms.from_np2d(arr, 0) ``` -------------------------------- ### Get or Set LabTalk String Variables Source: https://context7.com/originlab/originpro/llms.txt Gets the value of a LabTalk string variable or sets a new string variable. Useful for passing string data between Python and Origin. ```python import originpro as op # Get AppData path app_data = op.get_lt_str('%@Y') # Set a string variable op.set_lt_str('myvar', 'Hello World') value = op.get_lt_str('myvar') ``` -------------------------------- ### wks.to_df() - Get DataFrame from Worksheet Source: https://context7.com/originlab/originpro/llms.txt Creates a pandas DataFrame from worksheet data with options for column ranges and index selection. ```APIDOC ## [METHOD] wks.to_df() ### Description Creates a pandas DataFrame from worksheet data. ### Parameters #### Query Parameters - **c1** (int/str) - Optional - Starting column index or name - **numcols** (int) - Optional - Number of columns to retrieve - **cindex** (str) - Optional - Column name to use as DataFrame index - **head** (str) - Optional - User parameter row to use as column headers ### Request Example ```python import originpro as op wks = op.find_sheet() df = wks.to_df(c1='B', numcols=3, cindex='A') ``` ``` -------------------------------- ### Transfer DataFrame to Worksheet with wks.from_df() Source: https://context7.com/originlab/originpro/llms.txt Transfers a pandas DataFrame to an Origin worksheet. Supports specifying the starting column and including the DataFrame index. ```python import originpro as op import pandas as pd wks = op.new_sheet() # Create sample DataFrame df = pd.DataFrame({ 'Time': [1, 2, 3, 4, 5], 'Voltage': [1.2, 2.4, 3.1, 4.0, 5.2], 'Current': [0.5, 1.0, 1.5, 2.0, 2.5] }) # Set DataFrame to worksheet wks.from_df(df) ``` ```python # Set DataFrame starting at specific column wks.from_df(df, c1='D') ``` ```python # Include DataFrame index as a column wks.from_df(df, addindex=True) ``` -------------------------------- ### Set Graph Axis Title Source: https://context7.com/originlab/originpro/llms.txt Sets or gets the title text for an axis. Can be applied to primary or secondary Y axes. ```python import originpro as op gl = op.find_graph()[0] # Set axis titles ax = gl.axis('x') ax.title = 'Time (s)' ay = gl.axis('y') ay.title = 'Voltage (mV)' # For right Y axis ay2 = gl.axis('y2') ay2.title = 'Current (mA)' ``` -------------------------------- ### Set Worksheet Columns from Dictionary Source: https://context7.com/originlab/originpro/llms.txt Populate worksheet columns with data from a Python dictionary using `from_dict`. Keys become column short names, and values (lists) become column data. You can specify the starting column and row. ```python data = {'aa': [1, 2, 3], 'bb': [4, 5, 6], 'cc': [7, 8, 9]} wks.from_dict(data) ``` ```python wks.from_dict(data, col='D') ``` ```python wks.from_dict(data, row=5) ``` -------------------------------- ### Set Matrix XY Mapping Source: https://context7.com/originlab/originpro/llms.txt Sets or gets the XY coordinate mapping for a matrix sheet. Use this to define the data range for plotting or analysis. ```python import originpro as op ms = op.find_sheet('m') # Get current XY mapping x1, x2, y1, y2 = ms.xymap # Set XY mapping ms.xymap = (0, 100, 0, 50) ``` -------------------------------- ### Get Column Labels (Long Name, Units, Comments) Source: https://context7.com/originlab/originpro/llms.txt Retrieve text from column label rows using `get_label`. Specify the column by index or short name and the label type ('L' for long name, 'U' for units, 'C' for comments, 'G' for short name). ```python lname = wks.get_label(0, 'L') ``` ```python units = wks.get_label(1, 'U') ``` ```python comments = wks.get_label(2, 'C') ``` ```python sname = wks.get_label(0, 'G') ``` -------------------------------- ### Set Worksheet Column Data from List Source: https://context7.com/originlab/originpro/llms.txt Populate a worksheet column with data from a Python list using `from_list`. You can specify the column index or name, add metadata like long name, units, and comments, set column designation for plotting, and define the starting row. ```python wks.from_list(0, data) ``` ```python wks.from_list(1, data, lname='Voltage', units='mV', comments='Sensor A') ``` ```python wks.from_list(0, data, axis='X') ``` ```python wks.from_list(1, data, axis='Y') ``` ```python wks.from_list(0, data, start=5) ``` ```python wks.from_list('Intensity', data) ``` -------------------------------- ### Get Worksheet Column Data as List Source: https://context7.com/originlab/originpro/llms.txt Retrieve data from a worksheet column as a Python list using `to_list`. Data can be accessed by column index or name (short or long name). ```python data = wks.to_list(0) ``` ```python data = wks.to_list('Intensity') ``` ```python raw_data = wks.to_list(1) processed = [x * 2 for x in raw_data] wks.from_list(2, processed, lname='Processed') ``` -------------------------------- ### Open Project File with op.open() Source: https://context7.com/originlab/originpro/llms.txt Opens an existing Origin project file. Supports opening as read-only or with a save prompt for the current project. ```python import originpro as op # Open a project file op.open(r'C:\path\to\My Project.opju') ``` ```python # Open as read-only op.open(r'C:\path\to\project.opju', readonly=True) ``` ```python # Open with save prompt for current project op.open(r'C:\path\to\project.opju', asksave=True) ``` -------------------------------- ### Create or Find Image Windows Source: https://context7.com/originlab/originpro/llms.txt Creates a new image window or finds an existing one by name. If no name is provided, it finds the active image window. ```python import originpro as op # Create new image window im = op.new_image() # Find existing image window im = op.find_image('Image1') # Find active image im = op.find_image() ``` -------------------------------- ### Create New Workbook with op.new_book() Source: https://context7.com/originlab/originpro/llms.txt Creates a new workbook or matrixbook. Supports specifying type, long name, template, and hidden status. ```python import originpro as op # Create a new workbook with default settings wb = op.new_book() ``` ```python # Create workbook with long name wb = op.new_book('w', lname='My Data Book') ``` ```python # Create workbook from template wb = op.new_book('w', template='MyTemplate') ``` ```python # Create hidden workbook wb = op.new_book('w', hidden=True) ``` ```python # Create a matrix book mb = op.new_book('m', lname='Matrix Data') ``` -------------------------------- ### Save Project with op.save() Source: https://context7.com/originlab/originpro/llms.txt Saves the current Origin project. Can save to a new location or overwrite the current project file if it has been previously saved. ```python import originpro as op # Save to a new location op.save(r'C:\path\to\My Project.opju') ``` ```python # Save to current project file (must be previously saved) op.save() ``` -------------------------------- ### wks.from_file() - Import File via Data Connector Source: https://context7.com/originlab/originpro/llms.txt Imports data from files into a worksheet using Origin's Data Connector. ```APIDOC ## [METHOD] wks.from_file() ### Description Imports data from files using Origin's Data Connector. ### Parameters #### Request Body - **fn** (str) - Required - File path - **keep_DC** (bool) - Optional - Whether to keep the data connector - **dctype** (str) - Optional - Connector type (e.g., 'MATLAB') - **sel** (str) - Optional - Specific selection (e.g., sheet name) ``` -------------------------------- ### Project Management API Source: https://context7.com/originlab/originpro/llms.txt APIs for managing Origin projects, including creating, opening, saving, and retrieving path information. ```APIDOC ## op.new() - Create New Project ### Description Creates a new Origin project, optionally prompting to save the current project. ### Method `op.new()` ### Parameters - **asksave** (boolean) - Optional - If True, prompts to save the current project before creating a new one. ### Request Example ```python import originpro as op # Start a new project without save prompt op.new() # Start a new project with save prompt op.new(asksave=True) ``` ## op.open() - Open Project File ### Description Opens an existing Origin project file. ### Method `op.open(path, readonly=False, asksave=False)` ### Parameters - **path** (string) - Required - The full path to the Origin project file (.opju). - **readonly** (boolean) - Optional - If True, opens the project in read-only mode. - **asksave** (boolean) - Optional - If True, prompts to save the current project before opening the new one. ### Request Example ```python import originpro as op # Open a project file op.open(r'C:\path\to\My Project.opju') # Open as read-only op.open(r'C:\path\to\project.opju', readonly=True) # Open with save prompt for current project op.open(r'C:\path\to\project.opju', asksave=True) ``` ## op.save() - Save Project ### Description Saves the current project to file. ### Method `op.save(path=None)` ### Parameters - **path** (string) - Optional - The full path to save the project file. If not provided, saves to the current project file (must be previously saved). ### Request Example ```python import originpro as op # Save to a new location op.save(r'C:\path\to\My Project.opju') # Save to current project file (must be previously saved) op.save() ``` ## op.path() - Get Origin Paths ### Description Returns pre-defined Origin paths for common locations. ### Method `op.path(type)` ### Parameters - **type** (string) - Required - Specifies the type of path to retrieve. Common types include: - 'u': User Files folder - 'e': Origin Exe folder - 'p': Project folder - 'c': Learning Center folder - 'a': Attached file folder ### Request Example ```python import originpro as op # Get User Files folder user_folder = op.path('u') # Get Origin Exe folder exe_folder = op.path('e') # Get project folder project_folder = op.path('p') # Get Learning Center folder learning_center = op.path('c') # Get attached file folder attached_folder = op.path('a') # Example: Open sample project op.open(op.path('c') + r'Graphing\Trellis Plots - Box Charts.opju') ``` ``` -------------------------------- ### Load Image from File or URL Source: https://context7.com/originlab/originpro/llms.txt Loads an image into an image window from a local file path or a URL. Supports loading single images or image stacks using wildcards. ```python import originpro as op im = op.new_image() # Load single image fn = op.path('e') + r'Samples\Image Processing and Analysis\Flower.jpg' im.from_file(fn) # Load image stack with wildcard im.from_file(op.path('e') + r'Samples\Image Processing and Analysis\*.tif') # Load from URL im.from_file('https://example.com/image.tif') ``` -------------------------------- ### Open File Selection Dialog Source: https://context7.com/originlab/originpro/llms.txt Opens a file dialog to allow the user to select a file. Supports filtering by file type or custom extensions. ```python import originpro as op # Select Origin file fn = op.file_dialog('o') # Select image file fn = op.file_dialog('i') # Select text file fn = op.file_dialog('t') # Custom file types fn = op.file_dialog('*.png;*.jpg;*.bmp') ``` -------------------------------- ### op.new_graph() - Create New Graph Source: https://context7.com/originlab/originpro/llms.txt Creates a new graph page in OriginPro. ```APIDOC ## [METHOD] op.new_graph() ### Description Creates a new graph page. ### Parameters #### Request Body - **lname** (str) - Optional - Long name for the graph - **template** (str) - Optional - Template name or path - **hidden** (bool) - Optional - Whether to create the graph as hidden ``` -------------------------------- ### Find Existing Book with op.find_book() Source: https://context7.com/originlab/originpro/llms.txt Finds a workbook or matrixbook by name or index. If no name is provided, it finds the active book. ```python import originpro as op # Find active workbook wb = op.find_book() ``` ```python # Find workbook by name wb = op.find_book('w', 'Book1') ``` ```python # Find matrix book by name mb = op.find_book('m', 'MBook1') ``` ```python # Find book by index wb = op.find_book('w', 0) # First workbook ``` -------------------------------- ### Import CSV Data with OriginPro Connector Source: https://context7.com/originlab/originpro/llms.txt Use the op.Connector class for fine-grained control over CSV data import settings. Allows specifying partial row imports and modifying import settings before execution. ```python import originpro as op wks = op.find_sheet() # Create connector dc = op.Connector(wks, dctype='csv', keep_DC=True) # Get/modify import settings settings = dc.settings() partial = settings['partial'] partial[op.attrib_key('Use')] = '1' partial['row'] = '10:20' # Import rows 10-20 only # Import file f = op.path('e') + r'Samples\Import and Export\S15-125-03.dat' dc.imp(f) # Import into new sheet (e.g., another Excel sheet) dc.new_sheet('Sheet2') # Get data source print(dc.source) ``` -------------------------------- ### op.lt_exec - Execute LabTalk Script Source: https://context7.com/originlab/originpro/llms.txt Executes LabTalk script commands directly within the Origin environment. ```APIDOC ## op.lt_exec ### Description Executes LabTalk script directly. ### Method Function ### Parameters - **script** (string) - Required - The LabTalk command string to execute. ### Request Example ```python op.lt_exec('fitlr (1,2)') ``` ``` -------------------------------- ### Create New Graph Page Source: https://context7.com/originlab/originpro/llms.txt Generate a new graph page using `op.new_graph`. Options include creating an empty graph, specifying a long name, using a template (by name or path), or creating a hidden graph. ```python g = op.new_graph() ``` ```python g = op.new_graph(lname='My Plot') ``` ```python g = op.new_graph(template='scatter') ``` ```python g = op.new_graph(template=op.path('e') + '3Ys_Y-Y-Y.otp') ``` ```python g = op.new_graph(hidden=True) ``` -------------------------------- ### Add Sheet to Book with WBook.add_sheet() Source: https://context7.com/originlab/originpro/llms.txt Adds a new sheet to an existing workbook. Supports specifying the sheet name and whether to activate it upon creation. ```python import originpro as op wb = op.find_book('w', 'Book1') # Add new sheet with default name wks = wb.add_sheet() ``` ```python # Add sheet with specific name wks = wb.add_sheet('Results') ``` ```python # Add sheet without activating it wks = wb.add_sheet('Background', active=False) ``` -------------------------------- ### Perform Non-Linear Curve Fitting Source: https://context7.com/originlab/originpro/llms.txt Performs non-linear curve fitting using Origin's engine. Allows setting data, fixing parameters, defining bounds, and setting initial values. ```python import originpro as op wks = op.new_sheet() fn = op.path('e') + r'Samples\Curve Fitting\Gaussian.dat' wks.from_file(fn, False) # Create fitting model model = op.NLFit('Gauss') # Set data model.set_data(wks, x=0, y=1) # Optional: Fix parameters model.fix_param('y0', 0) # Optional: Set parameter bounds model.set_lbound('A', '>', 0) model.set_ubound('A', '<', 1000) # Optional: Set initial parameter values model.set_param('xc', 5) # Perform fit model.fit() # Get results as dictionary results = model.result() print(f"Amplitude: {results['A']}") # Or generate report sheet report_range, curve_range = model.report() report_wks = op.find_sheet('w', report_range) ``` -------------------------------- ### Import File into Worksheet via Data Connector Source: https://context7.com/originlab/originpro/llms.txt Use `from_file` to import data from various file types (CSV, Excel, MATLAB, etc.) using Origin's Data Connector. The `keep_DC` parameter controls whether the connector remains after import. You can also specify the connector type and selection criteria for certain file types. ```python fn = op.path('e') + r'Samples\Import and Export\donations.csv' wks.from_file(fn) ``` ```python wks.from_file(fn, keep_DC=False) ``` ```python wks.from_file(op.path() + 'data.xlsx') ``` ```python wks.from_file('data.mat', dctype='MATLAB') ``` ```python wks.from_file('workbook.xlsx', sel='Sheet2') ``` -------------------------------- ### Create New Sheet with op.new_sheet() Source: https://context7.com/originlab/originpro/llms.txt Creates a new worksheet or matrix sheet within a workbook. Supports specifying type, template, and hidden status. ```python import originpro as op # Create new worksheet wks = op.new_sheet() ``` ```python # Create new worksheet with template wks = op.new_sheet('w', template='MyTemplate.otwu') ``` ```python # Create new matrix sheet ms = op.new_sheet('m') ``` ```python # Create hidden sheet wks = op.new_sheet('w', hidden=True) ``` -------------------------------- ### Find Existing Graph Page Source: https://context7.com/originlab/originpro/llms.txt Locate a graph page using `op.find_graph`. You can find the active graph, a graph by its name, or by its index. Accessing layers within a graph is also demonstrated. ```python g = op.find_graph() ``` ```python g = op.find_graph('Graph1') ``` ```python g = op.find_graph(0) ``` ```python gl = op.find_graph('Graph1')[0] ``` -------------------------------- ### Export Graph to Image File Source: https://context7.com/originlab/originpro/llms.txt Exports a graph to an image file in various formats (PNG, EMF, SVG). Supports specifying width, format, and size ratio. ```python import originpro as op g = op.find_graph('Graph1') # Export as PNG with width g.save_fig(op.path() + 'plot.png', width=800) # Export as different format g.save_fig(op.path() + 'plot.emf') # Use last export settings (remembered in graph) g.save_fig() # Export with size factor for EMF/SVG g.save_fig(op.path() + 'plot.svg', ratio=150) ``` -------------------------------- ### Attach to or Detach from Origin Instance Source: https://context7.com/originlab/originpro/llms.txt Attaches to a running Origin instance in OriginExt mode or detaches. Also controls the visibility of the Origin window and can exit the application. ```python import originpro as op # Attach to running Origin instance op.attach() # ... perform operations ... # Detach when done op.detach() # Exit Origin application op.exit() # Show/hide Origin window op.set_show(True) # Show op.set_show(False) # Hide is_visible = op.get_show() ``` -------------------------------- ### Workbook and Worksheet Operations API Source: https://context7.com/originlab/originpro/llms.txt APIs for creating, finding, and manipulating workbooks and worksheets. ```APIDOC ## op.new_book() - Create New Workbook ### Description Creates a new workbook or matrixbook and returns the book object. ### Method `op.new_book(type='w', lname=None, template=None, hidden=False)` ### Parameters - **type** (string) - Optional - Type of book to create ('w' for workbook, 'm' for matrixbook). Defaults to 'w'. - **lname** (string) - Optional - Long name for the new book. - **template** (string) - Optional - Name of the template to use for creating the book. - **hidden** (boolean) - Optional - If True, creates a hidden book. Defaults to False. ### Request Example ```python import originpro as op # Create a new workbook with default settings wb = op.new_book() # Create workbook with long name wb = op.new_book('w', lname='My Data Book') # Create workbook from template wb = op.new_book('w', template='MyTemplate') # Create hidden workbook wb = op.new_book('w', hidden=True) # Create a matrix book mb = op.new_book('m', lname='Matrix Data') ``` ## op.new_sheet() - Create New Sheet ### Description Creates a new workbook/matrixbook and returns the first sheet. ### Method `op.new_sheet(type='w', template=None, hidden=False)` ### Parameters - **type** (string) - Optional - Type of sheet to create ('w' for worksheet, 'm' for matrix sheet). Defaults to 'w'. - **template** (string) - Optional - Name of the template to use for creating the sheet. - **hidden** (boolean) - Optional - If True, creates a hidden sheet. Defaults to False. ### Request Example ```python import originpro as op # Create new worksheet wks = op.new_sheet() # Create new worksheet with template wks = op.new_sheet('w', template='MyTemplate.otwu') # Create new matrix sheet ms = op.new_sheet('m') # Create hidden sheet wks = op.new_sheet('w', hidden=True) ``` ## op.find_book() - Find Existing Book ### Description Finds a workbook or matrixbook by name or index. ### Method `op.find_book(type='w', name=None)` ### Parameters - **type** (string) - Optional - Type of book to find ('w' for workbook, 'm' for matrixbook). Defaults to 'w'. - **name** (string or int) - Optional - Name or index of the book to find. If None, finds the active book. ### Request Example ```python import originpro as op # Find active workbook wb = op.find_book() # Find workbook by name wb = op.find_book('w', 'Book1') # Find matrix book by name mb = op.find_book('m', 'MBook1') # Find book by index wb = op.find_book('w', 0) # First workbook ``` ## op.find_sheet() - Find Existing Sheet ### Description Finds a worksheet or matrix sheet using Origin range notation or by name/index. ### Method `op.find_sheet(type='w', name=None)` ### Parameters - **type** (string) - Optional - Type of sheet to find ('w' for worksheet, 'm' for matrix sheet). Defaults to 'w'. - **name** (string or int) - Optional - Name or index of the sheet to find. Can be a range string (e.g., '[Book1]Sheet2') or a sheet name/index. If None, finds the active sheet. ### Request Example ```python import originpro as op # Find active worksheet wks = op.find_sheet() # Find specific sheet by range string wks = op.find_sheet('w', '[Book1]Sheet2') # Find active matrix sheet ms = op.find_sheet('m') # Find matrix by book name (assumes first sheet) ms = op.find_sheet('m', 'MBook1') # Find by index wks = op.find_sheet('w', 0) # First worksheet ``` ## WBook.add_sheet() - Add Sheet to Book ### Description Adds a new sheet to an existing workbook. ### Method `wb.add_sheet(name=None, active=True)` ### Parameters - **name** (string) - Optional - Name for the new sheet. If None, Origin assigns a default name. - **active** (boolean) - Optional - If True, the new sheet is activated. Defaults to True. ### Request Example ```python import originpro as op wb = op.find_book('w', 'Book1') # Add new sheet with default name wks = wb.add_sheet() # Add sheet with specific name wks = wb.add_sheet('Results') # Add sheet without activating it wks = wb.add_sheet('Background', active=False) ``` ``` -------------------------------- ### op.NLFit - Non-Linear Curve Fitting Source: https://context7.com/originlab/originpro/llms.txt Performs non-linear curve fitting using Origin's fitting engine. ```APIDOC ## op.NLFit ### Description Performs non-linear curve fitting using Origin's fitting engine. ### Method Class Method ### Parameters - **model_name** (string) - Required - The name of the fitting function (e.g., 'Gauss'). ### Request Example ```python model = op.NLFit('Gauss') model.set_data(wks, x=0, y=1) model.fit() ``` ### Response - **results** (dict) - Returns a dictionary containing the fit parameters and statistics. ``` -------------------------------- ### MSheet.from_np() - Set Matrix from NumPy Array Source: https://context7.com/originlab/originpro/llms.txt Populates a matrix sheet with data from a NumPy array. ```APIDOC ## MSheet.from_np() ### Description Sets matrix sheet data from a NumPy array. Supports 2D arrays and 3D arrays (multiple matrix objects). ### Parameters - **arr** (numpy.ndarray) - Required - The array containing data. - **dstack** (bool) - Optional - If True, uses different dimension order (row, col, depth). ``` -------------------------------- ### Find Existing Sheet with op.find_sheet() Source: https://context7.com/originlab/originpro/llms.txt Finds a worksheet or matrix sheet using Origin range notation or by name/index. If no range is provided, it finds the active sheet. ```python import originpro as op # Find active worksheet wks = op.find_sheet() ``` ```python # Find specific sheet by range string wks = op.find_sheet('w', '[Book1]Sheet2') ``` ```python # Find active matrix sheet ms = op.find_sheet('m') ``` ```python # Find by book name (assumes first sheet) ms = op.find_sheet('m', 'MBook1') ``` ```python # Find by index wks = op.find_sheet('w', 0) # First worksheet ``` -------------------------------- ### Execute LabTalk Script Source: https://context7.com/originlab/originpro/llms.txt Executes LabTalk script commands directly or on specific Origin objects like worksheet. ```python import originpro as op # Execute LabTalk commands op.lt_exec('impasc -dm') # Import with dialog op.lt_exec('fitlr (1,2)') # Quick linear fit # Execute on specific object wks = op.find_sheet() wks.lt_exec('wks.nCols=5') ``` -------------------------------- ### Wait for Operations Source: https://context7.com/originlab/originpro/llms.txt Waits for all pending recalculations to complete or for a specified duration. Useful for synchronizing operations. ```python import originpro as op # Wait for all recalculations to complete op.wait() # Wait specific seconds op.wait('s', 0.5) # Wait 0.5 seconds ``` -------------------------------- ### gl.rescale() - Rescale Axes Source: https://context7.com/originlab/originpro/llms.txt Updates axis limits to show all data within the graph layer. ```APIDOC ## gl.rescale() ### Description Updates axis limits to show all data. Can be configured to skip specific axes or colormap rescaling. ### Parameters - **axis** (str) - Optional - Specify 'x' or 'y' to rescale only that axis. - **mode** (str) - Optional - Specify 'm' to skip colormap rescale. ``` -------------------------------- ### Set Matrix Sheet Data from NumPy Array Source: https://context7.com/originlab/originpro/llms.txt Sets matrix sheet data from a NumPy array. Supports 2D and 3D arrays, with options for dimension ordering. ```python import originpro as op import numpy as np ms = op.new_sheet('m') # Set 2D array arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) ms.from_np(arr) # Set 3D array (multiple matrix objects) arr3d = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) ms.from_np(arr3d) # Set with different dimension order (row,col,depth) ms.from_np(arr3d, dstack=True) ``` -------------------------------- ### Set Graph Axis Limits Source: https://context7.com/originlab/originpro/llms.txt Sets axis scale limits for X and Y axes, optionally including a step value. Can also be set using property syntax. ```python import originpro as op gl = op.find_graph()[0] # Set X axis limits gl.set_xlim(0, 100) # Set Y axis limits with step gl.set_ylim(0, 50, 10) # Set only step value gl.set_xlim(step=5) # Use property syntax gl.xlim = (0, 100, 10) gl.ylim = (0, 50) ``` -------------------------------- ### Set Column Labels (Long Name, Units, Comments) Source: https://context7.com/originlab/originpro/llms.txt Use `set_label` to modify column label rows, including long name (default), units ('U'), comments ('C'), and user parameters ('Tag'). Specify the column by index or short name. ```python wks.set_label('A', 'Temperature') ``` ```python wks.set_label(1, 'Pressure') ``` ```python wks.set_label(0, 'K', type='U') ``` ```python wks.set_label(0, 'Measured at 25C', type='C') ``` ```python wks.set_label(1, 'Channel 1', 'Sensor') ``` -------------------------------- ### Rescale Graph Axes Source: https://context7.com/originlab/originpro/llms.txt Updates axis limits to show all data. Can rescale all axes, specific axes (e.g., 'x'), or skip colormap rescale ('m'). ```python import originpro as op gl = op.find_graph()[0] # Rescale all axes gl.rescale() # Rescale Y only (skip X) gl.rescale('x') # Skip colormap rescale gl.rescale('m') ``` -------------------------------- ### Evaluate LabTalk Numeric Expressions Source: https://context7.com/originlab/originpro/llms.txt Evaluates LabTalk expressions and returns numeric values as floats or integers. Useful for retrieving system information or calculated values. ```python import originpro as op # Get Origin version version = op.lt_float('@V') # Evaluate expression julian_date = op.lt_float('date(1/2/2020)') # Get color value green = op.lt_int('color("green")') ``` -------------------------------- ### g.save_fig() - Export Graph Source: https://context7.com/originlab/originpro/llms.txt Exports the current graph to an image file with specified dimensions or formats. ```APIDOC ## g.save_fig() ### Description Exports graph to an image file. Supports various formats like PNG, EMF, and SVG. ### Parameters - **path** (str) - Required - Full file path for the exported image. - **width** (int) - Optional - Width of the exported image. - **ratio** (int) - Optional - Size factor for vector formats like EMF/SVG. ``` -------------------------------- ### wks.from_list() - Set Column Data from List Source: https://context7.com/originlab/originpro/llms.txt Sets data from a Python list to a worksheet column, supporting metadata and axis designation. ```APIDOC ## [METHOD] wks.from_list() ### Description Sets data from a Python list to a worksheet column. ### Parameters #### Request Body - **col** (int/str) - Required - Column index or name - **data** (list) - Required - Data to set - **lname** (str) - Optional - Long name - **units** (str) - Optional - Units - **comments** (str) - Optional - Comments - **axis** (str) - Optional - Column designation (X, Y, etc.) - **start** (int) - Optional - Starting row index ``` -------------------------------- ### Perform Linear Regression Source: https://context7.com/originlab/originpro/llms.txt Performs linear curve fitting. Supports fixing slope or intercept and generating reports with confidence bands. ```python import originpro as op wks = op.find_sheet() # Create linear fit model lr = op.LinearFit() # Set data lr.set_data(wks, x=0, y=1) # Optional: Fix slope or intercept lr.fix_slope(1.0) # lr.fix_intercept(0) # Get results results = lr.result() slope = results['Parameters']['Slope']['Value'] slope_err = results['Parameters']['Slope']['Error'] intercept = results['Parameters']['Intercept']['Value'] r_squared = results['RegStats']['AdjRSquare'] # Or generate report with confidence bands report_range, curve_range = lr.report(band=3) # 3=both confidence and prediction ``` -------------------------------- ### Data Operations API Source: https://context7.com/originlab/originpro/llms.txt APIs for transferring data between pandas DataFrames and Origin worksheets. ```APIDOC ## wks.from_df() - Set DataFrame to Worksheet ### Description Transfers a pandas DataFrame to an Origin worksheet. ### Method `wks.from_df(df, c1='A', addindex=False)` ### Parameters - **df** (pandas.DataFrame) - Required - The pandas DataFrame to transfer. - **c1** (string) - Optional - The starting column for the data. Defaults to 'A'. - **addindex** (boolean) - Optional - If True, includes the DataFrame index as a column. Defaults to False. ### Request Example ```python import originpro as op import pandas as pd wks = op.new_sheet() # Create sample DataFrame df = pd.DataFrame({ 'Time': [1, 2, 3, 4, 5], 'Voltage': [1.2, 2.4, 3.1, 4.0, 5.2], 'Current': [0.5, 1.0, 1.5, 2.0, 2.5] }) # Set DataFrame to worksheet wks.from_df(df) # Set DataFrame starting at specific column wks.from_df(df, c1='D') # Include DataFrame index as a column wks.from_df(df, addindex=True) ``` ``` -------------------------------- ### Set DataFrame to Worksheet with Custom Header Source: https://context7.com/originlab/originpro/llms.txt Use the `from_df` method to write a pandas DataFrame to an Origin worksheet. Specify a character for the header row, such as 'C' for comments. ```python wks.from_df(df, head='C') ``` -------------------------------- ### Customize Data Plot Appearance Source: https://context7.com/originlab/originpro/llms.txt Customizes data plot appearance including color, symbol size, kind, and interior. Supports transparency and using column values for color mapping or symbol size. ```python import originpro as op gl = op.find_graph()[0] p = gl.plot_list()[0] # Set color (multiple formats) p.color = 'Red' p.color = '#ff0000' p.color = '#f00' p.color = (255, 0, 0) p.color = 2 # Color index # Set symbol properties p.symbol_size = 15 p.symbol_kind = 2 # 0=square, 1=circle, 2=up triangle, etc. p.symbol_interior = 1 # 0=no symbol, 1=solid, 2=open, 3=dot center # Set transparency (0-100%) p.transparency = 50 # Use column values for color mapping p.color = op.color_col() # Use next column as colormap p.colormap = 'Fire' # Use column values for symbol size p.symbol_size = op.modi_col(1) # Use next column p.symbol_sizefactor = 5 ``` -------------------------------- ### Add Graph Layer Source: https://context7.com/originlab/originpro/llms.txt Adds a new layer to a graph page, supporting different layer types like right Y axis or top X axis. Layer types are specified by index. ```python import originpro as op g = op.find_graph('Graph1') # Add right Y axis layer gl2 = g.add_layer(2) gl2.xlim = [-2, 1] # Add layer types (by index): # 0=bottom X top Y, 2=right Y, 3=top X, 4=top X right Y # See https://www.originlab.com/doc/X-Function/ref/layadd ``` -------------------------------- ### gl.add_plot() - Add Data Plot Source: https://context7.com/originlab/originpro/llms.txt Adds a data plot to a graph layer using column references or range strings. ```APIDOC ## gl.add_plot() ### Description Adds a data plot to a graph layer. Supports adding plots via column indices, column names, or range strings, and allows specifying plot types and error bars. ### Parameters - **wks** (object) - Required - The worksheet object containing the data. - **coly** (int/str) - Required - The Y column index or name. - **colx** (int/str) - Optional - The X column index or name. - **type** (str) - Optional - Plot type ('l'=line, 's'=scatter, 'y'=line+symbol, 'c'=column). - **colyerr** (int) - Optional - Column index for error bars. ``` -------------------------------- ### Add Data Plot to Graph Layer Source: https://context7.com/originlab/originpro/llms.txt Adds a data plot to a graph layer using column index, name, type, or range string. Customize plot appearance after adding. ```python import originpro as op wks = op.find_sheet('w', 'Book1') g = op.new_graph(template='scatter') gl = g[0] # First layer # Add plot with column index p = gl.add_plot(wks, coly=1, colx=0) # Add plot by column name p = gl.add_plot(wks, coly='Voltage', colx='Time') # Specify plot type: 'l'=line, 's'=scatter, 'y'=line+symbol, 'c'=column p = gl.add_plot(wks, coly=1, type='s') # Plot with error bars p = gl.add_plot(wks, coly=1, colx=0, colyerr=2) # Use row numbers as X p = gl.add_plot(wks, coly=1, colx='#') # Plot from range string p = gl.add_plot('[Book1]1!(1,2)', type='s') # Customize plot appearance p.color = '#f00' # Red p.symbol_size = 10 p.symbol_kind = 2 # Circle gl.rescale() ``` -------------------------------- ### Group/Ungroup Plots in Graph Layer Source: https://context7.com/originlab/originpro/llms.txt Groups or ungroups data plots within a graph layer for consistent formatting. Can group specific plots or ungroup all. ```python import originpro as op g = op.new_graph(template='scatter') gl = g[0] # Add multiple plots wks = op.find_sheet('w', 'Book1') gl.add_plot('[Book1]1!(A,B)') gl.add_plot('[Book1]1!(A,C)') # Group plots 0 and 1 gl.group(True, 0, 1) # Ungroup all gl.group(False) ``` -------------------------------- ### Set Graph Axis Scale Type Source: https://context7.com/originlab/originpro/llms.txt Sets the scale type for an axis (e.g., linear, log10). Access the axis object directly to set its scale. ```python import originpro as op gl = op.find_graph()[0] # Set X axis to log10 gl.xscale = 'log10' # Set Y axis to linear gl.yscale = 'linear' # Access axis object directly ax = gl.axis('x') ax.scale = 'log10' # Or use integer: ax.scale = 2 # Available scale types: # 'linear', 'log10', 'probability', 'probit', 'reciprocal', # 'offset_reciprocal', 'logit', 'ln', 'log2' ``` -------------------------------- ### Set Column Plotting Designations (X, Y, Z) Source: https://context7.com/originlab/originpro/llms.txt Assign plotting designations (X, Y, Z, etc.) to columns using `cols_axis`. You can set designations for all columns, a specific range, or clear all designations. ```python wks.cols_axis('xy') ``` ```python wks.cols_axis('nxy') ``` ```python wks.cols_axis('xyy', c1=0, c2=2) ``` ```python wks.cols_axis() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.