Hi, I'm new to qcustomplot and am having trouble with putting the y-axis text horizontally. I have at least 12 graphs showing in the customplot and I would like to have them all be self contained. In other words, each of these graphs will be able to hide and move to different positions so I want everything self contained for each graph. The way I tried to accomplished this was to use two subRects. The first would be positioned to have the greatest size available and the y-axis text written in it. The second would then be the actual graph. I do get most of it to work but the graph is now really small, but other than that, it looks like it would be correct.
customPlots->plotLayout()->addElement( 0, 0, subLayout ); QCPAxisRect *subRect0 = new QCPAxisRect( customPlots, false ); QCPAxisRect *subRect20 = new QCPAxisRect( customPlots, false ); subLayout->addElement( 0, 0, subRect0 ); subRect0->insetLayout()->addElement( subRect20, Qt::AlignLeft ); subRect20->setAutoMargins( QCP::msTop| QCP::msRight | QCP::msBottom ); subRect20->setMargins( QMargins(55,0,0,0) ); subRect20->addAxes( QCPAxis::atBottom | QCPAxis::atLeft ); subRect20->axis( QCPAxis::atBottom )->setTicks( false ); subRect20->axis( QCPAxis::atLeft )->setTicks( false ); QCPGraph *graph0 = customPlots->addGraph( subRect20->axis(QCPAxis::atBottom),subRect20->axis(QCPAxis::atLeft) ); graph0->setData( index_x, index_y ); graph0->rescaleAxes(); // add the text label at the left(y axis): QCPItemText *textLabel = new QCPItemText( customPlots ); customPlots->addItem( textLabel ); textLabel->setClipToAxisRect( false ); textLabel->setClipAxisRect( subRect0 ); textLabel->setPositionAlignment( Qt::AlignLeft|Qt::AlignHCenter ); textLabel->position->setType( QCPItemPosition:: ptAxisRectRatio );//ptAbsolute textLabel->position->setAxisRect( subRect0 ); textLabel->position->setCoords( 0, 0 ); // place position at center/top of axis rect textLabel->setText( "Index" ); textLabel->setFont( QFont(QFont().family(), 8) ); // make font a bit larger }
I know I'm doing something wrong so if anyone could give me a heads up, I would appreciate it.
Thanks