Plot Workbench: Difference between revisions

From FreeCAD Documentation
(If FreeCAD uses Python 2.7, you should have matplotlib for the same version)
("From FreeCAD 0.20 on" was apparently hard to understand for non-native speakers. Changed it to "Since FreeCAD 0.20".)
 
(25 intermediate revisions by 7 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:11-->
<!--T:13-->
{{Docnav|[[Path Workbench|Path Workbench]]|[[Points Workbench|Points Workbench]]|IconL=Path-Workbench.svg|IconR=PointsWorkbench.svg}}
[[Image:Workbench_Plot.svg|thumb|128px|Plot workbench icon]]


</translate>
</translate>
{{TOCright}}
[[Image:Workbench_Plot.svg|64px]]
<translate>
<translate>


== Introduction == <!--T:8-->
== Introduction == <!--T:8-->


<!--T:1-->
<!--T:17-->
FreeCAD is able to perform plots using the [https://matplotlib.org/ matplotlib] [[Python|Python]] library. A module is provided to this end, as an external add-on in version 0.19 and as a core component from version 0.20 on. Older versions of FreeCAD are not covered in this documentation.
{{TOCright}}

The [[Plot Workbench|Plot Workbench]] allows the user to edit and save output plots created from other workbenches and tools.
<!--T:18-->
The produced plots offer the standard [https://matplotlib.org/ matplotlib] tools to edit and save. On top of that, a [[Image:Workbench_Plot.svg|24px]] [[Plot_Workbench|Plot Workbench]] is provided as an external add-on offering more complete tools to edit the plot and save it. The add-on can be installed with the [[Std_AddonMgr|Add-on manager]].

==Module== <!--T:19-->

<!--T:20-->
The module can be invoked in a Python console or in a [[Macros|macro]]. The first thing you must do is importing the module. In FreeCAD 0.19 you must first install the [[Image:Workbench_Plot.svg|24px]] [[Plot_Workbench|Plot Workbench]] using the [[Std_AddonMgr|Add-on manager]], and then you can import Plot by typing:

<!--T:21-->
{{Code|code=
from freecad.plot import Plot
}}

<!--T:22-->
Since FreeCAD 0.20 the plot module is already packaged with the program, so you don't need to install any add-on, but just type:

<!--T:23-->
{{Code|code=
from FreeCAD.Plot import Plot
}}

<!--T:24-->
After that, you can plot a straight line from (0,0) to (1,2) just simply typing:

<!--T:25-->
{{Code|code=
Plot.plot([0, 1], [0, 2])
}}


<!--T:9-->
<!--T:26-->
You can find more complex examples in the [[Plot_Basic_tutorial|Plot Basic tutorial]] and the [[Plot_MultiAxes_tutorial|Plot MultiAxes tutorial]].
With the Plot workbench you can edit the working area, the axes, labels, titles, line styles, and other elements of plots.


<!--T:10-->
==Workbench Tools== <!--T:2-->
The Plot workbench is an abstraction of the [https://matplotlib.org/ matplotlib] [[Python|Python]] library conveniently adapted for FreeCAD. To use the Plot functions, the version of {{incode|matplotlib}} installed in your system should match the Python version that FreeCAD uses, that is, if FreeCAD uses Python 2.7, you should have {{incode|matplotlib}} for the same version.


==Tools== <!--T:2-->
<!--T:27-->
If you decide to install the [[Image:Workbench_Plot.svg|24px]] [[Plot_Workbench|Plot Workbench]] using the [[Std_AddonMgr|Add-on manager]], you will have the following tools available to manage the plots created with the module:


<!--T:3-->
<!--T:3-->
* [[Image:Plot_Save.png|32px]] [[Plot_Save|Save plot]]: Saves the plot in several formats. You can select the output size and resolution too.
* [[Image:Plot_Save.svg|32px]] [[Plot_Save|Save plot]]: Saves the plot in several formats. You can select the output size and resolution too.
* [[Image:Plot_Axes.png|32px]] [[Plot_Axes|Axes]]: Add, remove or edit plot axes.
* [[Image:Plot_Axes.svg|32px]] [[Plot_Axes|Axes]]: Add, remove or edit plot axes.
* [[Image:Plot_Series.png|32px]] [[Plot_Series|Series]]: Edit series title and styling.
* [[Image:Plot_Series.svg|32px]] [[Plot_Series|Series]]: Edit series title and styling.
* [[Image:Plot_Grid.png|32px]] [[Plot_Grid|Grid]]: Show/hide grid.
* [[Image:Plot_Grid.svg|32px]] [[Plot_Grid|Grid]]: Show/hide grid.
* [[Image:Plot_Legend.png|32px]] [[Plot_Legend|Legend]]: Show/hide legend.
* [[Image:Plot_Legend.svg|32px]] [[Plot_Legend|Legend]]: Show/hide legend.
* [[Image:Plot_Labels.png|32px]] [[Plot_Labels|Labels]]: Edit labels.
* [[Image:Plot_Labels.svg|32px]] [[Plot_Labels|Labels]]: Edit labels.
* [[Image:Plot_Positions.png|32px]] [[Plot_Positions|Positions]]: Set elements positions.
* [[Image:Plot_Positions.svg|32px]] [[Plot_Positions|Positions]]: Set elements positions.


==Scripting== <!--T:4-->
==Scripting== <!--T:28-->
Since the Plot Workbench is a layer on top of {{incode|matplotlib}}, you are free to use any function from this library on plot instances. See [[Scripting_examples|scripting examples]] for examples.


==Tutorial== <!--T:5-->
<!--T:4-->
Since the Plot Workbench is a layer on top of {{incode|matplotlib}}, you are free to use any function from this library on plot instances. See [[Scripting_and_macros|Scripting and macros]] for examples.
* [[Plot Basic tutorial]]
* [[Plot MultiAxes tutorial]]


<!--T:6-->
==Tutorial== <!--T:29-->
{{Docnav|[[Path Workbench|Path Workbench]]|[[Points Workbench|Points Workbench]]|IconL=Path-Workbench.svg|IconR=PointsWorkbench.svg}}


<!--T:12-->
<!--T:5-->
* [[Plot_Basic_tutorial|Plot Basic tutorial]]
{{Plot Tools navi}}
* [[Plot_MultiAxes_tutorial|Plot MultiAxes tutorial]]
{{Userdocnavi}}
[[Category:Workbenches]]




</translate>
</translate>
{{Plot_Tools_navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
[[Category:External_Workbenches{{#translation:}}]]
[[Category:Addons{{#translation:}}]]

Latest revision as of 16:48, 25 June 2022

Plot workbench icon

Introduction

FreeCAD is able to perform plots using the matplotlib Python library. A module is provided to this end, as an external add-on in version 0.19 and as a core component from version 0.20 on. Older versions of FreeCAD are not covered in this documentation.

The produced plots offer the standard matplotlib tools to edit and save. On top of that, a Plot Workbench is provided as an external add-on offering more complete tools to edit the plot and save it. The add-on can be installed with the Add-on manager.

Module

The module can be invoked in a Python console or in a macro. The first thing you must do is importing the module. In FreeCAD 0.19 you must first install the Plot Workbench using the Add-on manager, and then you can import Plot by typing:

from freecad.plot import Plot

Since FreeCAD 0.20 the plot module is already packaged with the program, so you don't need to install any add-on, but just type:

from FreeCAD.Plot import Plot

After that, you can plot a straight line from (0,0) to (1,2) just simply typing:

Plot.plot([0, 1], [0, 2])

You can find more complex examples in the Plot Basic tutorial and the Plot MultiAxes tutorial.

Workbench Tools

If you decide to install the Plot Workbench using the Add-on manager, you will have the following tools available to manage the plots created with the module:

  • Save plot: Saves the plot in several formats. You can select the output size and resolution too.
  • Axes: Add, remove or edit plot axes.
  • Series: Edit series title and styling.
  • Grid: Show/hide grid.
  • Legend: Show/hide legend.
  • Labels: Edit labels.
  • Positions: Set elements positions.

Scripting

Since the Plot Workbench is a layer on top of matplotlib, you are free to use any function from this library on plot instances. See Scripting and macros for examples.

Tutorial