pan

How do I capture the point initially tapped in a UIPanGestureRecognizer?

半城伤御伤魂 提交于 2019-12-03 06:47:58
问题 I have an app that lets the user trace lines on the screen. I am doing so by recording the points within a UIPanGestureRecognizer: -(void)handlePanFrom:(UIPanGestureRecognizer *)recognizer { CGPoint pixelPos = [recognizer locationInView:rootViewController.glView]; NSLog(@"recorded point %f,%f",pixelPos.x,pixelPos.y); } That works fine. However, I'm very interested in the first point the user tapped before they began panning. But the code above only gives me the points that occurred after the

Pan/zoom ordinal scale?

一个人想着一个人 提交于 2019-12-03 03:09:46
I am using d3 to render a simplified gantt chart, with panning and zooming using d3.behavior.zoom. The x scale is a time scale (slightly modified to center calendar days in columns, etc) and works beatifully, but I'm having problems deciding how to zoom/pan the y scale, whose domain is a list of tasks which will often be too many to fit in the chart area, so the need for panning/zooming. Is there a way to tell the default ordinal scale to react to zoom/pan events, or should I write a custom scale? And if I need to write a custom scale, would it be better to base it on d3.scale.ordinal (having

How to programatically pan a VisualizationViewer with Jung (the java library)?

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: After a lot a investigations, I don't achieve to find a convenient answer to the following question: how to programatically pan a VisualizationViewer with Jung? I have a GUI with the list of the vertices of my graph, and I want that a double click on one item of the list (i.e. a node description) perform a "centering action" of my VisualizationViewer for the clicked node. How to code such a behavior? it seems simple but I found no convenient answer. If someone could help, thanks! njames 回答1: Here is how to popup a menu after right-clicking

Formatting of DateTimeIndex in plot pandas

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm having trouble deciphering the documentation for changing tick frequency and date formatting with pandas. For example: import numpy as np import pandas as pd import pandas.io.data as web import matplotlib as mpl %matplotlib inline mpl.style.use('ggplot') mpl.rcParams['figure.figsize'] = (8,6) # grab some price data px = web.DataReader('AAPL', "yahoo", '2010-12-01')['Adj Close'] px_m = px.asfreq('M', method='ffill') rets_m = px_m.pct_change() rets_m.plot(kind='bar') generates this plot: Yikes. How can I get the ticks to be every month or

replacing empty strings with NaN in Pandas

匿名 (未验证) 提交于 2019-12-03 02:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a pandas dataframe (that was created by importing a csv file). I want to replace blank values with NaN. Some of these blank values are empty and some contain a (variable number) of spaces '' , ' ' , ' ' , etc. Using the suggestion from this thread I have df.replace(r'\s+', np.nan, regex=True, inplace = True) which does replace all the strings that only contain spaces, but also replaces every string that has a space in it, which is not what I want. How do I replace only strings with just spaces and empty strings? 回答1: Indicate it has

Extracting just Month and Year from Pandas Datetime column (Python)

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Dataframe, df, with the following column: df['ArrivalDate'] = ... 936 2012-12-31 938 2012-12-29 965 2012-12-31 966 2012-12-31 967 2012-12-31 968 2012-12-31 969 2012-12-31 970 2012-12-29 971 2012-12-31 972 2012-12-29 973 2012-12-29 ... The elements of the column are pandas.tslib.Timestamp. I want to just include the year and month. I thought there would be simple way to do it, but I can't figure it out. Here's what I've tried: df['ArrivalDate'].resample('M', how = 'mean') I got the following error: Only valid with DatetimeIndex or

Groupby with User Defined Functions Pandas

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I understand that passing a function as a group key calls the function once per index value with the return values being used as the group names. What I can't figure out is how to call the function on column values. So I can do this: people = DataFrame ( np . random . randn ( 5 , 5 ), columns =[ 'a' , 'b' , 'c' , 'd' , 'e' ], index =[ 'Joe' , 'Steve' , 'Wes' , 'Jim' , 'Travis' ]) def GroupFunc ( x ): if len ( x ) > 3 : return 'Group1' else : return 'Group2' people . groupby ( GroupFunc ). sum () This splits the data into two groups

Dual y axis in ggplot2 for multiple panel figure

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: We can not easily create the dual y axis with ggplot2. kohske provided a solution to add dual y axis for single panel figures ( http://rpubs.com/kohske/dual_axis_in_ggplot2 ) @Andreas show an example to align two plots with ggplot2 (still single panel figures) ( Plot with 2 y axes, one y axis on the left, and another y axis on the right ) These tricks can not work if figures have multiple panels (created by geom_wrap or geom_grid), e.g. 4 panel figure below. I would like to add the axis of p1 to the right side of panels of merged

Remove rows with duplicate indices (Pandas DataFrame and TimeSeries)

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm reading some automated weather data from the web. The observations occur every 5 minutes and are compiled into monthly files for each weather station. Once I'm done parsing a file, the DataFrame looks something like this: Sta Precip1hr Precip5min Temp DewPnt WindSpd WindDir AtmPress Date 2001-01-01 00:00:00 KPDX 0 0 4 3 0 0 30.31 2001-01-01 00:05:00 KPDX 0 0 4 3 0 0 30.30 2001-01-01 00:10:00 KPDX 0 0 4 3 4 80 30.30 2001-01-01 00:15:00 KPDX 0 0 3 2 5 90 30.30 2001-01-01 00:20:00 KPDX 0 0 3 2 10 110 30.28 The problem I'm having is that

I want to multiply two columns in a pandas DataFrame and add the result into a new column

匿名 (未验证) 提交于 2019-12-03 02:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trying to multiply two existing columns in a pandas Dataframe (orders_df) - Prices (stock close price) and Amount (stock quantities) and add the calculation to a new column called 'Value'. For some reason when I run this code, all the rows under the 'Value' column are positive numbers, while some of the rows should be negative. Under the Action column in the DataFrame there are seven rows with the 'Sell' string and seven with the 'Buy' string. for i in orders_df . Action : if i == 'Sell' : orders_df [ 'Value' ] = orders_df .