René's URL Explorer Experiment


Title: Control plot refactoring for consistent functionality by murrayrm · Pull Request #1034 · python-control/python-control · GitHub

Open Graph Title: Control plot refactoring for consistent functionality by murrayrm · Pull Request #1034 · python-control/python-control

X Title: Control plot refactoring for consistent functionality by murrayrm · Pull Request #1034 · python-control/python-control

Description: This PR makes a (fairly large) number of changes to control plotting functions to provide consistent functionality. The majority of changes involve making functionality that was present in some plot functions but not others available consistently across all _plot() functions. Everything is backward compatible with v0.10.0. Summary of changes: Change output format for plotting commands to a ControlPlot object, with lines, axes, legend, etc available. Accessing this object as a list is backward compatible with 10.0 format (with deparecation warning). Make processing of the ax keyword consistent across all plotting functions (using ctrlplot._process_ax_keyword). Fix up the label keyword to operate in a consistent and more intuitive manner: labels can be specified as a single string, a simple list, or an array (for MIMO and multi-trace systems). If a single list is given for a MIMO or multi-trace system, it is reshaped as needed. Change ct.suptitle() to cplt.set_plot_title() (where cplt is the returned ControlPlot obect from a plotting command), and update the plot() method to provide uniform processing of the title keyword (when present, overrides title). Deprecated the relabel keyword in time_response_plot. This didn't seem to be that useful and was not implemented for other functions. Updated legend processing to be consistent across all plotting functions, as described in the user documention (below). Includes unit tests + docstring updates. Updated the use of rcParams for control plotting functions: defaults are now in ct.rcParams and can be reset using ct.reset_rcParams. Set up uniform processing of the rcParams keyword argument for plotting functions (with unit tests). Unified color and *fmt argument processing code, in addition to color management for sequential plotting (_get_color_offset, _get_color). Put together a sample code skeleton for creating a control plots (at the top of ctrlplot.py. Unit tests to make sure all plotting commands perform consistently, including documentation checks. Documentation of new functionality (from plotting.rst): Customizing control plots A set of common options are available to customize control plots in various ways. The following general rules apply: If a plotting function is called multiple times with data that generate control plots with the same shape for the array of subplots, the new data will be overlaid with the old data, with a change in color(s) for the new data (chosen from the standard matplotlib color cycle). If not overridden, the plot title and legends will be updated to reflect all data shown on the plot. If a plotting function is called and the shape for the array of subplots does not match the currently displayed plot, a new figure is created. Note that only the shape is checked, so if two different types of plotting commands that generate the same shape of subplots are called sequentially, the matplotlib.pyplot.figure command should be used to explicitly create a new figure. The ax keyword argument can be used to direct the plotting function to use a specific axes or array of axes. The value of the ax keyword must have the proper number of axes for the plot (so a plot generating a 2x2 array of subplots should be given a 2x2 array of axes for the ax keyword). The color, linestyle, linewidth, and other matplotlib line property arguments can be used to override the default line properties. If these arguments are absent, the default matplotlib line properties are used and the color cycles through the default matplotlib color cycle. The :func:~control.bode_plot, :func:~control.time_response_plot, and selected other commands can also accept a matplotlib format string (e.g., 'r--'). The format string must appear as a positional argument right after the required data argument. Note that line property arguments are the same for all lines generated as part of a single plotting command call, including when multiple responses are passed as a list to the plotting command. For this reason it is often easiest to call multiple plot commands in sequence, with each command setting the line properties for that system/trace. The label keyword argument can be used to override the line labels that are used in generating the title and legend. If more than one line is being plotted in a given call to a plot command, the label argument value should be a list of labels, one for each line, in the order they will appear in the legend. For input/output plots (frequency and time responses), the labels that appear in the legend are of the form ", , , ". The trace name is used only for multi-trace time plots (for example, step responses for MIMO systems). Common information present in all traces is removed, so that the labels appearing in the legend represent the unique characteristics of each line. For non-input/output plots (e.g., Nyquist plots, pole/zero plots, root locus plots), the default labels are the system name. If label is set to False, individual lines are still given labels, but no legend is generated in the plot (this can also be accomplished by setting legend_map to False. Note: the label keyword argument is not implemented for describing function plots or phase plane plots, since these plots are primarily intended to be for a single system. Standard matplotlib commands can be used to customize these plots for displaying information for multiple systems. The legend_loc, legend_map and show_legend keyword arguments can be used to customize the locations for legends. By default, a minimal number of legends are used such that lines can be uniquely identified and no legend is generated if there is only one line in the plot. Setting show_legend to False will suppress the legend and setting it to True will force the legend to be displayed even if there is only a single line in each axes. In addition, if the value of the legend_loc keyword argument is set to a string or integer, it will set the position of the legend as described in the matplotlib.legend documentation. Finally, legend_map can be set to an` array that matches the shape of the subplots, with each item being a string indicating the location of the legend for that axes (or None for no legend). The rcParams keyword argument can be used to override the default matplotlib style parameters used when creating a plot. The default parameters for all control plots are given by the ct.rcParams dictionary and have the following values: Key Value ‘axes.labelsize’ ‘small’ ‘axes.titlesize’ ‘small’ ‘figure.titlesize’ ‘medium’ ‘legend.fontsize’ ‘x-small’ ‘xtick.labelsize’ ‘small’ ‘ytick.labelsize’ ‘small’ Only those values that should be changed from the default need to be specified in the rcParams keyword argument. To override the defaults for all control plots, update the ct.rcParams dictionary entries. The default values for style parameters for control plots can be restored using :func:~control.reset_rcParams. The title keyword can be used to override the automatic creation of the plot title. The default title is a string of the form " plot for " where is a list of the sys names contained in the plot (which can be updated if the plotting is called multiple times). Use title=False to suppress the title completely. The title can also be updated using the control.ControlPlot.set_plot_title method for the returned control plot object. The plot title is only generated if ax is None. The following code illustrates the use of some of these customization features:: P = ct.tf([0.02], [1, 0.1, 0.01]) # servomechanism C1 = ct.tf([1, 1], [1, 0]) # unstable L1 = P * C1 C2 = ct.tf([1, 0.05], [1, 0]) # stable L2 = P * C2 plt.rcParams.update(ct.rcParams) fig = plt.figure(figsize=[7, 4]) ax_mag = fig.add_subplot(2, 2, 1) ax_phase = fig.add_subplot(2, 2, 3) ax_nyquist = fig.add_subplot(1, 2, 2) ct.bode_plot( [L1, L2], ax=[ax_mag, ax_phase], label=["$L_1$ (unstable)", "$L_2$ (unstable)"], show_legend=False) ax_mag.set_title("Bode plot for $L_1$, $L_2$") ax_mag.tick_params(labelbottom=False) fig.align_labels() ct.nyquist_plot(L1, ax=ax_nyquist, label="$L_1$ (unstable)") ct.nyquist_plot( L2, ax=ax_nyquist, label="$L_2$ (stable)", max_curve_magnitude=22, legend_loc='upper right') ax_nyquist.set_title("Nyquist plot for $L_1$, $L_2$") fig.suptitle("Loop analysis for servomechanism control design") plt.tight_layout()

Open Graph Description: This PR makes a (fairly large) number of changes to control plotting functions to provide consistent functionality. The majority of changes involve making functionality that was present in some pl...

X Description: This PR makes a (fairly large) number of changes to control plotting functions to provide consistent functionality. The majority of changes involve making functionality that was present in some pl...

Opengraph URL: https://github.com/python-control/python-control/pull/1034

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:407f9b72-7923-0790-fe42-9c83577e1921
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idE646:17B78D:1E4044A:2AA5368:697A5536
html-safe-nonceabf87410159c9247fb4838cd1327319f257ba17e898eda27b2a1c06095fc5b4b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjQ2OjE3Qjc4RDoxRTQwNDRBOjJBQTUzNjg6Njk3QTU1MzYiLCJ2aXNpdG9yX2lkIjoiMzMxNTQwNDU5MzIxODM0NDI0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaccd22f6a766275ea2b7b5f13c0f586ba42c7c1582f93becb3447b308f7de6a6e0
hovercard-subject-tagpull_request:1980043397
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python-control/python-control/pull/1034/checks
twitter:imagehttps://avatars.githubusercontent.com/u/293362?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/293362?s=400&v=4
og:image:altThis PR makes a (fairly large) number of changes to control plotting functions to provide consistent functionality. The majority of changes involve making functionality that was present in some pl...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonea2296221ffa83b7f45f8ba9b62e1aed869492cb43693309e51b8111607e38282
turbo-cache-controlno-preview
go-importgithub.com/python-control/python-control git https://github.com/python-control/python-control.git
octolytics-dimension-user_id2285872
octolytics-dimension-user_loginpython-control
octolytics-dimension-repository_id22791752
octolytics-dimension-repository_nwopython-control/python-control
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id22791752
octolytics-dimension-repository_network_root_nwopython-control/python-control
turbo-body-classeslogged-out env-production page-responsive full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release46d8a07df71eb59259545c68ce36abf1075d2fca
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-control/python-control/pull/1034/checks#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fpull%2F1034%2Fchecks
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fpull%2F1034%2Fchecks
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=python-control%2Fpython-control
Reloadhttps://github.com/python-control/python-control/pull/1034/checks
Reloadhttps://github.com/python-control/python-control/pull/1034/checks
Reloadhttps://github.com/python-control/python-control/pull/1034/checks
python-control https://github.com/python-control
python-controlhttps://github.com/python-control/python-control
Notifications https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Fork 447 https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Star 2k https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Code https://github.com/python-control/python-control
Issues 87 https://github.com/python-control/python-control/issues
Pull requests 8 https://github.com/python-control/python-control/pulls
Discussions https://github.com/python-control/python-control/discussions
Actions https://github.com/python-control/python-control/actions
Projects 0 https://github.com/python-control/python-control/projects
Wiki https://github.com/python-control/python-control/wiki
Security 0 https://github.com/python-control/python-control/security
Insights https://github.com/python-control/python-control/pulse
Code https://github.com/python-control/python-control
Issues https://github.com/python-control/python-control/issues
Pull requests https://github.com/python-control/python-control/pulls
Discussions https://github.com/python-control/python-control/discussions
Actions https://github.com/python-control/python-control/actions
Projects https://github.com/python-control/python-control/projects
Wiki https://github.com/python-control/python-control/wiki
Security https://github.com/python-control/python-control/security
Insights https://github.com/python-control/python-control/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython-control%2Fpython-control%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython-control%2Fpython-control%2Fissues%2Fnew%2Fchoose
murrayrmhttps://github.com/murrayrm
python-control:mainhttps://github.com/python-control/python-control/tree/main
murrayrm:ctrlplot_updates-27Jun2024https://github.com/murrayrm/python-control/tree/ctrlplot_updates-27Jun2024
Conversation 27 https://github.com/python-control/python-control/pull/1034
Commits 34 https://github.com/python-control/python-control/pull/1034/commits
Checks 0 https://github.com/python-control/python-control/pull/1034/checks
Files changed https://github.com/python-control/python-control/pull/1034/files
Please reload this pagehttps://github.com/python-control/python-control/pull/1034/checks
Please reload this pagehttps://github.com/python-control/python-control/pull/1034/checks
Control plot refactoring for consistent functionality https://github.com/python-control/python-control/pull/1034/checks#top
Please reload this pagehttps://github.com/python-control/python-control/pull/1034/checks
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.