Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to superscript figures?
Hi all,

I wrote a function which plots rectangles filled or not. If I use flag == 0 I want rectangles filled, in case of flag == 1 I want only the contour of the rectangles. Here's my function:

#!/usr/bin/env python3

import numpy as np
import matplotlib.pyplot as plt
import matplotlib 
#from matplotlib.patches import Polygon
#from matplotlib.collections import PatchCollection

def tabular(X,dx,p,prism,flag):

    fig = plt.figure()
    ax = fig.add_subplot(111)
    for i in range(prism):
        xl = (p[i,2]-p[i,3]/2)
        if p[i,1] < 0:

        if flag == 0:
            rect = matplotlib.patches.Rectangle((xl,p[i,4]), p[i,3], vm-p[i,4], color=cor)
            plt.xlim(X[0], X[-1])
            plt.ylim([0, vm])
            ax = plt.gca()
        elif flag == 1:
            rect = matplotlib.patches.Rectangle((xl,p[i,4]), p[i,3], vm-p[i,4], linestyle = '--', fill = False)
            plt.xlim(X[0], X[-1])
            plt.ylim([0, vm])
            ax = plt.gca()
    plt.title('Disposição de Prismas')
    plt.ylabel('Profundidade (m)')
The function works well. But, I want to call it two times. In the first one, I need to plot color rectangles. In the second one, I want to change the arguments and plot the results, only with the contour, in the same figure. The final result needs to be a single figure with colorful and contour rectangles. A superscription similar to the function 'hold on' from Matlab is that what I want.

At this moment my code produces two figures as you can see below, but the perfect result is the combination of both:



Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  matplotlib.pyplot functions create new figures instead of applying to the current one karkas 2 267 Jul-09-2020, 08:32 AM
Last Post: karkas
  Loss and Accuracy Figures. Hani 3 665 May-20-2020, 06:55 PM
Last Post: jefsummers
  How to create matplotlib subplots from figures vitaly 3 509 Mar-02-2020, 12:58 AM
Last Post: scidam
  Superimpose figures Scientifix 2 2,371 Aug-16-2019, 04:06 PM
Last Post: Nitram

Forum Jump:

Users browsing this thread: 1 Guest(s)