Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to superscript figures?
#1
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):
    vm=3*max(p[:,4])

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

        if flag == 0:
            rect = matplotlib.patches.Rectangle((xl,p[i,4]), p[i,3], vm-p[i,4], color=cor)
            ax.add_patch(rect)
            plt.xlim(X[0], X[-1])
            plt.ylim([0, vm])
            ax = plt.gca()
            ax.invert_yaxis()
        elif flag == 1:
            rect = matplotlib.patches.Rectangle((xl,p[i,4]), p[i,3], vm-p[i,4], linestyle = '--', fill = False)
            ax.add_patch(rect)
            plt.xlim(X[0], X[-1])
            plt.ylim([0, vm])
            ax = plt.gca()
            ax.invert_yaxis()
    plt.title('Disposição de Prismas')
    plt.xlabel('Posição(m)')
    plt.ylabel('Profundidade (m)')
    plt.show()
    return
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:

İmage

İmage
Quote

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)