Hello im struggling with a plot and tried already for several hours but could not finde a way to solve my issue.
I have the simplified date like:
test = pd.DataFrame({'Date': [2020-12-30, 2020-12-30,2020 - 12 - 30, 2020 - 12 - 31, 2020 - 12 - 31, 2021 - 0o1 - 0o1, 2021 - 0o1 - 0o1], 'Adj Close': [500,600,400,300,500,700,800], 'Sentiment': ['Positive', 'Positive', 'Negative', 'Negative','Negative', 'Positive', 'Positive'], 'num_tweets': [70, 80, 50, 50, 30, 90, 70]})
With the Output:
Date Adj Close Sentiment num_tweets
2020-12-27 500 Positive 70
2020-12-28 600 Positive 80
2020-12-29 400 Negative 50
2020-12-30 300 Negative 50
2020-12-31 500 Negative 30
2021-01-01 700 Positive 90
2021-01-02 800 Positive 70
I ploted the Adj Close and the Sentiment with a line plot and scatterplot but im not able to get the num_tweets as a barplot into the plot or in the smae timeline in a second sub plot. I attached the plot i got so far with the code:
fig, axes = plt.subplots(2, 1, figsize=(20, 10), gridspec_kw={'height_ratios': [3, 1]})
sns.lineplot(ax=axes[0], x=df_plot["Date"], y=df_plot["Adj Close"])
sns.scatterplot(ax=axes[0], x=df_plot["Date"], y=df_plot["Adj Close"], hue=df_plot['Sentiment'], palette=['g', 'y', 'r'])
fig.suptitle("Stock market of Netfilx from Jan-2018 to Sep-2022", fontsize=16)
sns.barplot(ax=axes[1], x=df_plot["Date"], y=df_plot["num_tweets"], data=df_plot, edgecolor='black',
errorbar=('ci', False),
palette='Blues_r')
plt.ylabel('count')
plt.xlabel('')
#plt.xticks(df_plot["Date"])
plt.show()
My Problem with the subplot is that even though im ploting from the same data im getting every single day printed which leads to the long black line with unreadable dates and also that the sub plot is wider and is not fitting to the main plot.
I also tried to plot the num_tweets into the same plot and with and second y-axes but im only getting the barplot without the other ones as result.
Anyone any idea how to tackle that?