Graphique en mode discret pour les variables binaires et numériques

This commit is contained in:
Philippe Roy 2023-01-31 13:51:32 +01:00
parent 4d809d45da
commit a3746f9ec7
4 changed files with 27 additions and 9 deletions

View File

@ -110,7 +110,27 @@ def csv_read(file):
# Création des graphiques
###############################################################################
def plot_static(canvas, fields, xdata, ydata, plot_config, title):
# Création d'une courbe
def plot_draw(plt, var, xdata, ydata, plot_config):
# Courbe d'une variable analogique (continue)
if plot_config_get(plot_config, var, 'type') =='a':
plt.plot(xdata, ydata, label=var, color=plot_config_get(plot_config, var, 'color'), linewidth=plot_config_get(plot_config, var, 'linewidth'),
linestyle=plot_config_get(plot_config, var, 'linestyle'), marker=plot_config_get(plot_config, var, 'marker'))
# Courbe d'une variable binaire (discret)
if plot_config_get(plot_config, var, 'type') =='d':
plt.plot(xdata, ydata, label=var, drawstyle='steps-post', color=plot_config_get(plot_config, var, 'color'), linewidth=plot_config_get(plot_config, var, 'linewidth'),
linestyle=plot_config_get(plot_config, var, 'linestyle'), marker=plot_config_get(plot_config, var, 'marker'))
plt.set_ylim(0,1) # niveau 0 et niveau 1
# Courbe d'une variable numérique (discret)
if plot_config_get(plot_config, var, 'type') =='n':
plt.plot(xdata, ydata, label=var, drawstyle='steps-post', color=plot_config_get(plot_config, var, 'color'), linewidth=plot_config_get(plot_config, var, 'linewidth'),
linestyle=plot_config_get(plot_config, var, 'linestyle'), marker=plot_config_get(plot_config, var, 'marker'))
# Création des graphiques statiques
def plots_static(canvas, fields, xdata, ydata, plot_config, title):
# Configuration des plots activée
plot_config_enable=plot_config_get_enable()
@ -152,8 +172,7 @@ def plot_static(canvas, fields, xdata, ydata, plot_config, title):
# Création du plot unique
if plot_nb(plot_config) ==1:
if plot_config_enable: # Configuration des plots activée
canvas.plt.plot(xdata[i], ydata[i], label=var, color=plot_config_get(plot_config, var, 'color'), linewidth=plot_config_get(plot_config, var, 'linewidth'),
linestyle=plot_config_get(plot_config, var, 'linestyle'), marker=plot_config_get(plot_config, var, 'marker'))
plot_draw(canvas.plt, var, xdata[i], ydata[i], plot_config)
else:
canvas.plt.plot(xdata[i], ydata[i], '.-', label=var) # Configuration matplotlib par défaut
@ -166,8 +185,7 @@ def plot_static(canvas, fields, xdata, ydata, plot_config, title):
# Création des subplots
if plot_nb(plot_config) >1:
if plot_config_enable: # Configuration des plots activée
canvas.plt[plt_current].plot(xdata[i], ydata[i], label=var, color=plot_config_get(plot_config, var, 'color'), linewidth=plot_config_get(plot_config, var, 'linewidth'),
linestyle=plot_config_get(plot_config, var, 'linestyle'), marker=plot_config_get(plot_config, var, 'marker'))
plot_draw(canvas.plt[plt_current], var, xdata[i], ydata[i], plot_config)
else:
canvas.plt[plt_current].plot(xdata[i], ydata[i], '.-', label=var) # Configuration matplotlib par défaut

View File

@ -1,5 +1,5 @@
import sys
from twin_plot import plot_config_get_dict, plot_config_get, plot_config_get_enable, plot_nb, csv_read, plot_static # Gestion communes des graphiques (Qt, wx)
from twin_plot import plot_config_get_dict, plot_config_get, plot_config_get_enable, plot_nb, csv_read, plots_static # Gestion communes des graphiques (Qt, wx)
from PyQt5 import QtCore, QtGui, QtWidgets # GUI Qt5
import matplotlib # Grapheur Matplotlib
@ -178,7 +178,7 @@ class MainWindow(QtWidgets.QMainWindow):
# Création des graphive à partir du fichier CSV
fields, xdata, ydata = csv_read(sys.argv[1])
plot_static(self.canvas, fields, xdata, ydata, plot_config, sys.argv[1])
plots_static(self.canvas, fields, xdata, ydata, plot_config, sys.argv[1])
self.show()
###############################################################################

View File

@ -1,5 +1,5 @@
import sys
from twin_plot import plot_config_get_dict, plot_config_get, plot_config_get_enable, plot_nb, csv_read, plot_static # Gestion communes des graphiques (Qt, wx)
from twin_plot import plot_config_get_dict, plot_config_get, plot_config_get_enable, plot_nb, csv_read, plots_static # Gestion communes des graphiques (Qt, wx)
import wx # GUI wxPython
import matplotlib # Grapheur Matplotlib
@ -145,7 +145,7 @@ class CanvasFrame(wx.Frame):
# Création des graphive à partir du fichier CSV
fields, xdata, ydata = csv_read(sys.argv[1])
plot_static(self.canvas, fields, xdata, ydata, plot_config, sys.argv[1])
plots_static(self.canvas, fields, xdata, ydata, plot_config, sys.argv[1])
self.show()
# # Dessin