Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

How to change Root Locus plot color #789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AlHasanSony opened this issue Nov 13, 2022 · 1 comment
Closed

How to change Root Locus plot color #789

AlHasanSony opened this issue Nov 13, 2022 · 1 comment

Comments

@AlHasanSony
Copy link

The plot color of the roots seems like similiar while using rlocus function. Instead of showing the default color, we wanted to show different color.
So, how to change the color of the desired plot which used rlocus

@roryyorke
Copy link
Contributor

This was already asked for in #350.

For now, you can findobj the lines after plotting, and then set the colours:

import numpy as np
import matplotlib.pyplot as plt

import control as ct

# bit of a hack
def findlines(artist):
    return (isinstance(artist, plt.Line2D)
            and artist.get_linestyle()=='-'
            and isinstance(artist.get_xdata(), np.ndarray))

g = ct.tf([1],[1,1]) * ct.tf([1,3],[1,2]) * ct.tf([1],[1,1,16])

ct.rlocus(g);

h = plt.gca().findobj(match=findlines)

for i, h_ in enumerate(h): h_.set_color(f'C{i}')

plt.show()

image

@python-control python-control locked and limited conversation to collaborators Nov 27, 2022
@murrayrm murrayrm converted this issue into discussion #803 Nov 27, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants