salut j'ai un code python que j'aimerais convertir en code matlab. comment faire?
Show older comments
import pandas as pd
import plotly.express as px
import matplotlib.pyplot as plt
import numpy as np
import plotly.graph_objects as go
from sklearn.linear_model import LinearRegression
df = px.data.iris()
fig=px.scatter(df, x="sepal_width", y="sepal_length", color="species", marginal_y="violin",
marginal_x="box", trendline="ols", template= "simple_white")
fig.show()
print(df)
print(fig)
import plotly.graph_objects as go
fig1 = go.Figure()
for name, group in df.groupby('species'):
Legendgroup = group.groupby('species')
fig1.add_scatter(name=name, x = group['sepal_width'], y = group['sepal_length'], mode ='markers')
fig1.add_box(name=name, x = group['sepal_width'], notched = True)
fig1.add_violin(name=name, y = group['sepal_length'])
fig1.show()
groupObj = df.groupby('species')
for name, columns in df.groupby('species'):
print
print(columns)
df = px.data.iris()
fig1 = go.Figure()
for species, group in df.groupby('species'):
fig1.add_trace(go.Scatter(
legendgroup = species, x = group['sepal_width'], y = group['sepal_length'], xaxis="x1", yaxis="y1", mode='markers', name=f'{species}')
)
fig1.add_trace(go.Box(
showlegend=False, legendgroup=species, x = group['sepal_width'], name=f'{species}', notched=True, yaxis="y2" )
)
fig1.add_trace(go.Violin(
showlegend=False, legendgroup=species, y = group['sepal_length'], name=f'{species}', xaxis="x2")
)
fig1.add_trace(go.Scatter(
legendgroup=species, showlegend=False, name=species, x = group['sepal_width'],
y = LinearRegression().fit(group['sepal_width'].values.reshape((-1, 1)), group['sepal_length']).predict(group['sepal_width'].values.reshape(-1, 1)), mode='lines'
))
fig1. update_layout(
title='Scatter_boxplot_violin',
xaxis=dict(title='sepal_width', domain=[0, 0.71]), yaxis=dict(title='Sepal length', domain=[0, 0.71]), showlegend=True,
xaxis2=dict(domain=[0.75 ,1], showline=False, showticklabels=False, ticks=''),
yaxis2=dict(domain=[0.75 ,1], showline=False),
template='simple_white'
)
fig1.update_traces(
marker_color='#1F77B4',
selector=dict(name='setosa')
) #1F77B4
fig1.update_traces(
marker_color='#FF7F0E',
selector=dict(name='versicolor')
) #FF7F0E
fig1.update_traces(
marker_color='#2CA02C',
selector=dict(name='virginica')
) #2CA02C
fig1.show()
Answers (0)
Categories
Find more on Particle & Nuclear Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!