.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/00-basic/04-set-plot-properties.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_00-basic_04-set-plot-properties.py: .. _ref_set_plot_properties: How to set plot properties ========================== When working with a table, you can turn it into a plot by specifying the plot type through the `plot` property. Once a table is converted you can alter all sorts of plot properties by accessing properties on the item object. .. note:: This example assumes that you have a local Ansys installation. Initially, you must create and start a session as per other examples. .. GENERATED FROM PYTHON SOURCE LINES 20-26 Start an Ansys Dynamic Reporting service ---------------------------------------- Start an Ansys Dynamic Reporting service on a new database. The path for the database directory must be to an empty directory. .. GENERATED FROM PYTHON SOURCE LINES 26-35 .. code-block:: Python import numpy as np import ansys.dynamicreporting.core as adr db_dir = "C:\\tmp\\new_database" adr_service = adr.Service(db_directory=db_dir) session_guid = adr_service.start(create_db=True) .. GENERATED FROM PYTHON SOURCE LINES 36-42 Create a simple table --------------------- Start by creating a simple table and visualizing it. Create a table with 5 columns and 2 rows. .. GENERATED FROM PYTHON SOURCE LINES 42-49 .. code-block:: Python my_table = adr_service.create_item(obj_name="Table") my_table.table_dict["rowlbls"] = ["Row 1", "Row 2"] my_table.item_table = np.array( [["1", "2", "3", "4", "5"], ["1", "4", "9", "16", "25"]], dtype="|S20" ) .. GENERATED FROM PYTHON SOURCE LINES 50-53 Once you have created a table, set it to be a plot by changing its properties, and then you can set other properties. .. GENERATED FROM PYTHON SOURCE LINES 53-61 .. code-block:: Python # Set visualization to be plot instead of table my_table.plot = "line" # Set X axis and axis formatting my_table.xaxis = "Row 1" my_table.format = "floatdot1" .. GENERATED FROM PYTHON SOURCE LINES 62-64 Properties can also be inspected this way. .. GENERATED FROM PYTHON SOURCE LINES 64-75 .. code-block:: Python print(my_table.type) # Close the service # ----------------- # # Close the Ansys Dynamic Reporting service. The database with the items that # were created remains on disk. # sphinx_gallery_thumbnail_path = '_static/00_create_db_0.png' adr_service.stop() .. _sphx_glr_download_examples_00-basic_04-set-plot-properties.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 04-set-plot-properties.ipynb <04-set-plot-properties.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 04-set-plot-properties.py <04-set-plot-properties.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 04-set-plot-properties.zip <04-set-plot-properties.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_