FreeCAD Logo FreeCAD 1.0
  • Английский Африкаанс Арабский Белорусский Каталанский Чешский Немецкий Греческий Испанский Испанский Баскский Финский Филиппинский Французский Галисийский Хорватский Венгерский Индонезийский Итальянский Японский Кабильский Корейский Литовский Нидерландский Норвежская букмол Польский Португальский Португальский Румынский Русский Словацкий Словенский Сербский Шведский Турецкий Украинский Валенсианский Вьетнамский Китайский Китайский
  • Возможности
  • Скачать
  • Блог
  • Документация
    Индекс документации Приступая к работе Пользовательская документация Руководство по FreeCAD Документация верстаков Документация по кодированию на Python Документация по коду C++ Уроки Часто задаваемые вопросы Политика конфиденциальности О программе FreeCAD
  • Внести вклад
    Как помочь Sponsor Сообщить об ошибке Сделать запрос Задачи и финансирование Руководство по участию в разработке Руководство для разработчиков Переводы
  • Сообщество
    Кодекс поведения Форум The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Календарь
  • ♥ Donate

Donate

$
Информация о SEPA
Пожалуйста, настройте банковский перевод SEPA:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Банковское агентство: BNP Paribas Fortis
Адрес: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!

Руководство
Тема
Plot Workbench
Уровень
Beginner
Время для завершения
Авторы
FreeCAD версия
Примеры файлов
Смотрите также
None

In this tutorial we will learn how to create a basic plot using the Plot Workbench and the Python console.

Basic plot example

In the image you can see the result that we will approximately obtain. Following this tutorial you will learn:

  • How to create a Plot from the Python console.
  • How to plot some data from the Python console.
  • How to show the grid lines.
  • How to show the legend.
  • How to edit series labels, introducing text in LaTeX.
  • How to edit axes labels, introducing text in LaTeX.
  • How to edit series styles.
  • How to save your plot.

Plotting data

To plot data you don't need a FreeCAD document, simply open the Python console and start sending commands, or use macros.

Creating plot document

Plots are special documents that can be created manually in order to add data later, or the workbench can create one automatically when you start plotting data. Creating your own plot document has two advantages:

  • You can set the document window label.
  • You can control the document where you plot your data.

To create a new plot document simply launch the following commands:

try:
    from FreeCAD.Plot import Plot
except ImportError:
    from freecad.plot import Plot

Plot.figure("TrigonometricTest")

In FreeCAD version 0.19 it is required to install the Plot Workbench with the Add-on manager, while from FreeCAD version 0.20 onward the external add-on is no longer required to perform plots. The commands above will create a new tab in the Main view area called TrigonometricTest. The newly created document already has a set of axes. Each plot document has at least one set of axes.

Drawing functions

You can also start working from here because, as already explained, the plot command will create a new document if required. The next thing we need to do is create the data for the sine and cosine functions that we want to plot:

import math
t = range(0,101)
t = [tt/100.0 for tt in t]
s = [math.sin(2.0*math.pi*tt) for tt in t]
c = [math.cos(2.0*math.pi*tt) for tt in t]

That will create 3 arrays of data (with 101 points):

  • t = Time in seconds.
  • s = Sine function.
  • c = Cosine function.

In order to plot both functions we only need to launch the next commands:

Plot.plot(t,s)
Plot.plot(t,c)

The plot command allows the series label as an argument, but since we will edit it later using the Plot workbench tools, we don't pass this data yet.

Configuring plot

Showing grid and legend

Change the FreeCAD workbench to the Plot Workbench with View → Workbench → Plot (you must install the add-on first with the Add-on manager). When the workbench has been loaded, use the grid tool to show the grid.

Show/hide grid tool icon

You can repeat the action to hide the grid. Use the legend tool to show, or hide, the legend.

Show/hide legend tool icon

As you can see, the legend is very small and empty because we have not set any series label yet. In the Plot Workbench series without a label are not displayed in the legend.

Setting series label

With the series tool you can edit the parameters of each series.

Series configuration tool icon

Select the series you want to edit, we will start with the first one. Uncheck No label and set this label:

$y = \sin \left( 2 \pi t \right)$

Since matplotlib supports LaTeX you can set all labels and titles using LaTeX. Set the following label for the second series:

$y = \cos \left( 2 \pi t \right)$

Setting series style

You can set many series properties. Try to set the properties shown in the example image, changing the colors and drawing style of the second series.

Setting axes labels

With the labels tool you can set the title and the labels for the axes.

Labels tool icon

Set this data:

  • Title = Trigonometric functions example
  • X Label = $t$
  • Y Label = $y = \mathrm{f} \left( t \right)$

Also change the font size of the title and all labels to 20.

Saving plot

With the save tool you can save your plot as an image file in several formats.

Save tool icon

First select the path and filename for the output file.

Set the output image size in inches, for example use 11.7x8.3 to get a DIN A4 size. DPI (Dots per inch) will control the image resolution, for example use 100 dpi. In combination with the given dimensions this will result in an image of 1170x830 pixels.


Эта страница получена от https://wiki.freecad.org/Plot_Basic_tutorial

Свяжитесь с нами!
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

©Команда FreeCAD. Авторы изображений (сверху вниз): ppemawm, r-frank, epileftric, regis, regis, rider_mortagnais, bejant.

Этот проект поддерживается: , KiCad Services Corp. и другие спонсоры

GitHubУлучшить эту страницу на GitHub