python-ggplot

Python Simple Exponential Smoothing

醉酒当歌 提交于 2021-02-17 06:47:15
问题 I downloaded a TESLA stock from www.nasdaq.com; and after I downloaded the CSV file I realized that I need convert the CSV by using Microsoft Excel 2016. I use the Data Tab; and click Text to Columns. The header is clear now, they are: date, close, volume, open, high, low. Please see the csv file here. LinK: https://drive.google.com/open?id=1cirQi47U4uumvA14g6vOmgsXbV-YvS4l Preview (The CSV data is from 02/02/2017 until 02/02/2018): 1. date | close | volume | open | high | low | 2. 02/02/2018

plotnine doesn't add legend

牧云@^-^@ 提交于 2020-06-01 07:43:25
问题 I'm using plotnine to plot two graphs in the same plot. one graph uses the 'b' values from the dataframe you'll see below, and another one uses the values from 'c'. All I need is to show a simple legend legend where I see 'c' and 'b' with their according color. def plot_log_detected(): df = DataFrame({'x': [1, 2, 3, 4, 5], 'b': >>>SOME VALUES DOESNT MATTER<<<, 'c': >>>SOME VALUES DOESNT MATTER<<< }) return ggplot(aes(x='x', y='b'), data=df) + geom_point(size=1) +\ geom_line(aes(y='b'), color=

Plotting event density in Python with ggplot and pandas

偶尔善良 提交于 2020-01-14 15:00:11
问题 I am trying to visualize data of this form: timestamp senderId 0 735217 106758968942084595234 1 735217 114647222927547413607 2 735217 106758968942084595234 3 735217 106758968942084595234 4 735217 114647222927547413607 5 etc... geom_density works if I don't separate the senderId s: df = pd.read_pickle('data.pkl') df.columns = ['timestamp', 'senderId'] plot = ggplot(aes(x='timestamp'), data=df) + geom_density() print plot The result looks as expected: However if I want to show the senderId s

Python ggplot rotate axis labels

我怕爱的太早我们不能终老 提交于 2020-01-13 07:49:14
问题 when I tried to plot a timeseries with ggplot, the x axis lables became too crowded and overlapped each other: The code is: plot = ggplot(df, aes(x=df.index, weight='COUNT')) + \ geom_bar() + \ xlab('Date') + \ ylab('Incidents') I tried to add the following line + theme(axis.text.x = element_text(angle = 90, hjust = 1)) to the plot, but it doesn't work. And this extra line gives me error: SyntaxError: keyword can't be an expression close failed in file object destructor: sys.excepthook is

How do I make stat_smooth work in ggplot-python?

﹥>﹥吖頭↗ 提交于 2020-01-03 17:06:55
问题 That's my code: import pandas as pd import pandas.io.sql as sqlio from ggplot import * from db import conn sql = "SELECT * FROM history WHERE time > (NOW() - INTERVAL '1 day')::date" df = sqlio.read_frame(sql, conn) conn.close() lng = pd.melt(df[['time', 'players', 'servers']], id_vars='time') plt = ggplot(aes(x='time', y='value', colour='variable'), data=lng) + \ geom_line() + \ stat_smooth(colour='red', se=True) + \ ggtitle('Players and servers online over last 24h') + \ xlab("Time of the

Python ggplot format axis number as percent not functioning

ε祈祈猫儿з 提交于 2019-12-24 01:48:09
问题 Been loving the new ggplot module in Python but I haven't been able to format my y labels as percent instead of decimals. The below code produces the following image. Note that the labels = 'percent' code does not produce the intended format. plot = ggplot(aes(x='Date', y='return', color='Stocks'),data=rx) +\ geom_line() +\ scale_x_date(breaks=date_breaks('1 day'), labels='%b %d %Y') +\ scale_y_continuous(labels= 'percent') +\ ylab('Cumulative Return') + ggtitle('S&P Sector Performance') 回答1:

Group Bar Chart with Seaborn/Matplotlib

为君一笑 提交于 2019-12-24 00:35:27
问题 My goal is to create a grouped bar chart like the one below, using a pandas DataFrame that is grouped by two variables "Alpha" and "Beta." xl2 = xl.groupby(['Alpha','Beta']).median() When I tried this, a KeyError was thrown on 'Alpha' import seaborn as sns sns.barplot(x=['Alpha', 'Beta'], y=xl2['Gamma']) My hope was to pass in a list of x values to index on ('Alpha' and 'Beta'), and graph the associated 'Gamma." The documentation for the seaborn.barplot function doesn't provide any group bar

Is there a Python API for R's ggplot2? [closed]

廉价感情. 提交于 2019-12-23 10:58:07
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . My question is as simple as the title: i want to use R 's ggplot2 but all my data handling is done in Python : is there a Python API for ggplot2 , or an easy way to use ggplot2 through Python ? 回答1: RPy allows you to call R from Python and provides with data conversion utilities. You can use ggplot2 function with

Why Python ggplot returns name 'aes' is not defined?

一世执手 提交于 2019-12-23 07:49:38
问题 When I use the following comand p = ggplot(aes(x='DTM',y='TMP1'), data=data) I get the following error NameError: name 'aes' is not defined Could you help me? 回答1: You need to import aes : from ggplot import aes Alternatively, you can just import everything in the ggplot namespace (though * imports are usually frowned upon as they make it difficult to track down where a name is coming from): from ggplot import * 来源: https://stackoverflow.com/questions/23457513/why-python-ggplot-returns-name

How can I add a python's ggplot object to a matplot grid?

落爺英雄遲暮 提交于 2019-12-20 03:05:57
问题 My pandas DataFrame results_print has 2-dim arrays that are images. I print them like so: n_rows = results_print.shape[0] n_cols = results_print.shape[1] f, a = plt.subplots(n_cols, n_rows, figsize=(n_rows, n_cols)) methods = ['img', 'sm', 'rbd', 'ft', 'mbd', 'binary_sal', 'sal'] for r in range(n_rows): for c, cn in zip(range(len(methods)), methods): a[c][r].imshow(results_print.at[r,cn], cmap='gray') Now I created a python ggplot image object: gg = ggplot(aes(x='pixels'), data=DataFrame({