Seite 1 von 1

Achse normieren

Verfasst: Donnerstag 27. Juli 2017, 15:01
von sports7

Code: Alles auswählen

import os
import csv
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl #Add "as mpl" for command in line 36
import pylab as py
import xlsxwriter



histNumBins = 150
histAxisMin = 0
histAxisMax = 0,6


#------------------------------------------------------------------------------------
    #Draw histogram
#------------------------------------------------------------------------------------        
    fig = plt.figure()
    ax1 = fig.add_subplot(111)
  

    histIntra = ax1.hist(intraData, histNumBins, range = [histAxisMin, histAxisMax], label = "ID", facecolor = "b")
    ax1.set_xlabel("HD")
    ax1.set_ylabel("EA")
    ax1.set_ylim([0, len(iData)])
    ax1.tick_params("y", colors = "b")
    ax1.grid()
    x = np.linspace(histAxisMin, histAxisMax, 500)  
    yAx1 = gaussFunc(x, max(histI[0]), iMean, iStd)
    #plt.plot(x, yAx1, color="orange")    
    
    ax2 = ax1.twinx()
    histE = ax2.hist(eData, histNumBins, range = [histAxisMin, histAxisMax], label = "ID", facecolor = "g")
    ax2.set_ylabel("EA2")
    ax2.tick_params("y", colors = "g")
    

    yAx2 = gaussFunc(x, max(histE[0]), eMean, eStd)
    plt.plot(x, yAx2, color="orange")
Die iData und eData lese ich aus einem csv. file aus, das klappt auch und das Histogramm wird geplottet. Das einzige Problem ist jetzt noch die Normierung. Dabei sollen nur die histE-Daten normiert (auf 1) werden, also die Skala der ax2-y-Achse). Weiß jemand wie das funktioniert?

Viele Grüße
cyc7

Re: Achse normieren

Verfasst: Montag 31. Juli 2017, 14:30
von Sr4l
Ja. Wenn du die Daten die du plottest normalisiert sind ist auch die Ausgabe normalisiert dafür kannst du zum Beispiel deine Daten verändern.

Man kann auch die Achsen-Beschriftung von Hand ändern, das ist aber keine sehr schöne Lösung.