我在我的故事板(iPad)中定义了一个包含a的视图UICollectionView,在视图的底部还有一个UIToolbar.在UICollectionView我添加了一个UICollectionViewCell(由iPadCellCollectionViewCell类实现),其中包含另一个视图,它是一个Core-Plot Graph(一个CPTGraphHostingView类).
我有一个名为X的类来实现UICollectionViewDelegate和UICollectionViewDataSource.
在类X中,我构建了我的视图的每个单元格(在ViewDidLoad)Core-Plot Graph中,我有以下代码将图形链接到UICollectionViewCell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellId = @"ChartCollectionId";
iPadCellCollectionViewCell* cell = [self.theCollectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
MyChart* chart = [_charts objectAtIndex:indexPath.row];
cell.hostingView.hostedGraph = chart.barChart;
return cell;
Run Code Online (Sandbox Code Playgroud)
}
它工作正常,我的所有图表都正确显示在屏幕上.当用户滚动视图时,会出现问题,然后一个或多个单元格变为"空白".我真的不明白为什么.
我已经找到一个解决办法,而不是添加CPTGraphHostingView在UICollectionViewCell在界面生成器,我建立它自己和以前的代码变为:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellId = @"ChartCollectionId";
iPadCellCollectionViewCell* cell = [self.theCollectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
[cell.contentView addSubview:[_hostingViews objectAtIndex:indexPath.row]]; …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Core-Plot更改条形图中标签的默认位置.我正在使用这种方法:
-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)idx;
Run Code Online (Sandbox Code Playgroud)
我回来了:
return textLayer = [[CPTTextLayer alloc] initWithText:@"2222" style:textStyle];
Run Code Online (Sandbox Code Playgroud)
我得到这个结果:

但我想表现如下:

任何的想法?我试图在文档上找到答案,但我一直不可能.
I have a data frame with 190 observations (rows). There are five columns, in which every entry either has the value 0 or 1.
How do I get a barplot that has the name of the five columns on the x-Axis and the number of 1's (i.e. the sum) of every column as height of the bars - preferably with ggplot?
I'm sorry I don't have any sample data, I couldn't figure out how to produce a smaller dataframe that …