Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

adding objects to existing legend

from matplotlib import pyplot as plt
fig, ax = plt.subplots()
ax.plot([0,1,2,3,4,5,6], label='linear')
ax.plot([0,1,4,9,16,25,36], label='square')
lgd = ax.legend(loc='lower right')

def add_patch(legend):
    from matplotlib.patches import Patch
    ax = legend.axes

    handles, labels = ax.get_legend_handles_labels()
    handles.append(Patch(facecolor='orange', edgecolor='r'))
    labels.append("Color Patch")

    legend._legend_box = None
    legend._init_legend_box(handles, labels)
    legend._set_loc(legend._loc)
    legend.set_title(legend.get_title().get_text())


add_patch(lgd)

plt.show()
Comment

adding objects to existing legend


from matplotlib import pyplot as plt
fig, ax = plt.subplots()
ax.plot([0,1,2,3,4,5,6], label='linear')
ax.plot([0,1,4,9,16,25,36], label='square')
lgd = ax.legend(loc='lower right')

def add_patch(legend):
    from matplotlib.patches import Patch
    ax = legend.axes

    handles, labels = ax.get_legend_handles_labels()
    handles.append(Patch(facecolor='orange', edgecolor='r'))
    labels.append("Color Patch")

    legend._legend_box = None
    legend._init_legend_box(handles, labels)
    legend._set_loc(legend._loc)
    legend.set_title(legend.get_title().get_text())


add_patch(lgd)

plt.show()

Comment

PREVIOUS NEXT
Code Example
Typescript :: Vulnerability of systems is divided into two (2) categories. List the two (2) categories. 
Typescript :: check jasmine version 
Typescript :: to move a directory with its contents in terminal in linux 
Typescript :: Ionic toast animation 
Typescript :: sorting list of multiple in an ascending order 
Typescript :: move between points in godot 
Typescript :: exits adn copy file in java 
Typescript :: tkinter widgets overview 
Typescript :: collection that accepts duplicate keys 
Typescript :: post data 
Typescript :: react native elements header not fixing status bar color 
Typescript :: xargs / parallel 
Typescript :: rspec run all tests in a directory 
Typescript :: vestacp ports mysql 
Typescript :: typescript object of objects 
Typescript :: real time charts in flutter 
Typescript :: how to add type using map in typescript 
Typescript :: You’re asked to read a file a line at a time. For each line, you have to split it into fields. Which of the following sets of pseudo class definitions is likely to be more orthogonal? 
Cpp :: how to convert string to wchar_t in c++ 
Cpp :: print set c++ 
Cpp :: c++ vector print 
Cpp :: c++ hide cursor 
Cpp :: set platformio to C++17 
Cpp :: C++ red text output 
Cpp :: c++ ros subscriber 
Cpp :: how to run code in devcpp 
Cpp :: dev c++ tahe last word error 
Cpp :: pairs 
Cpp :: how to specify how many decimal to print out with std::cout 
Cpp :: random in range c++ 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =