How to change the color of a graph in PySide2How do I merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?How to print colored text in terminal in Python?How do I sort a dictionary by value?How to make a chain of function decorators?How to make a flat list out of list of lists?How do I list all files of a directory?Use of *args and **kwargs

Can a microwave oven cook chicken?

Can you use a clue that contains a word on the board within it in an unrelated way in Codenames?

Are results that are derived simply by using more computational power publishable?

Are there any (natural) scientists in Middle-earth?

Single word for being half in this world, half in some other spooky plane of existence

Is the sentence "pay some in cash" understandable?

A feasible and efficient method of fast global travel?

Mostly pluses and minuses: says Grandpa

How to translate old German (before 1920)

Does the horse hair in a bow all go in the same direction?

When and why did the Daily Prophet become the Ministry's mouthpiece?

Selecting elements of a list based on range

How do HK restaurants keep wok-fried scallops white, with no visible sear marks?

Why do the Rebels probe the section of the shield within the gate?

Why is hydro-electric power still scarce in some places?

What is this yellow sticky substance Mulder puts in his vodka?

Why does Greedo say "Maclunkey" in the Mos Eisley Cantina?

Doubt about Taylor series: do successive derivatives on a point determine the whole function?

Does the coriolis force have an effect on the direction in which an aircraft travels?

Does the sun cross other spiral arms in its movement around the galaxy's center?

Why don't we shield existing CPUs from radiation instead of designing new ones?

What is this machine's purpose?

What is smallest addressable value in an octal number called?

How to respond to requests to retest, in hope that the bug is gone?



How to change the color of a graph in PySide2


How do I merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?How to print colored text in terminal in Python?How do I sort a dictionary by value?How to make a chain of function decorators?How to make a flat list out of list of lists?How do I list all files of a directory?Use of *args and **kwargs






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









2

















I'm making a simple graph in PySide2 and was just wondering if you can change the color to something else. This is currently my code.



series = QtCharts.QLineSeries()

series.append(0,0)
series.append(1,7)
series.append(1.2,14)
series.append(1.3,21)
series.append(1.4,28)
series.append(1.5,35)

self.chartView = QtCharts.QChartView(self)
self.chartView.chart().addSeries(series)
self.chartView.chart().createDefaultAxes()
self.chartView.resize(600, 480)


Any help would be great










share|improve this question




























  • Do you want to change the color of the line or the background?

    – eyllanesc
    Mar 28 at 22:11











  • Forgot to mention that, the color of the line

    – Jan Novak
    Mar 28 at 22:33

















2

















I'm making a simple graph in PySide2 and was just wondering if you can change the color to something else. This is currently my code.



series = QtCharts.QLineSeries()

series.append(0,0)
series.append(1,7)
series.append(1.2,14)
series.append(1.3,21)
series.append(1.4,28)
series.append(1.5,35)

self.chartView = QtCharts.QChartView(self)
self.chartView.chart().addSeries(series)
self.chartView.chart().createDefaultAxes()
self.chartView.resize(600, 480)


Any help would be great










share|improve this question




























  • Do you want to change the color of the line or the background?

    – eyllanesc
    Mar 28 at 22:11











  • Forgot to mention that, the color of the line

    – Jan Novak
    Mar 28 at 22:33













2












2








2








I'm making a simple graph in PySide2 and was just wondering if you can change the color to something else. This is currently my code.



series = QtCharts.QLineSeries()

series.append(0,0)
series.append(1,7)
series.append(1.2,14)
series.append(1.3,21)
series.append(1.4,28)
series.append(1.5,35)

self.chartView = QtCharts.QChartView(self)
self.chartView.chart().addSeries(series)
self.chartView.chart().createDefaultAxes()
self.chartView.resize(600, 480)


Any help would be great










share|improve this question

















I'm making a simple graph in PySide2 and was just wondering if you can change the color to something else. This is currently my code.



series = QtCharts.QLineSeries()

series.append(0,0)
series.append(1,7)
series.append(1.2,14)
series.append(1.3,21)
series.append(1.4,28)
series.append(1.5,35)

self.chartView = QtCharts.QChartView(self)
self.chartView.chart().addSeries(series)
self.chartView.chart().createDefaultAxes()
self.chartView.resize(600, 480)


Any help would be great







python pyside2 qtcharts






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 22:11









eyllanesc

116k12 gold badges41 silver badges76 bronze badges




116k12 gold badges41 silver badges76 bronze badges










asked Mar 28 at 22:07









Jan NovakJan Novak

233 bronze badges




233 bronze badges















  • Do you want to change the color of the line or the background?

    – eyllanesc
    Mar 28 at 22:11











  • Forgot to mention that, the color of the line

    – Jan Novak
    Mar 28 at 22:33

















  • Do you want to change the color of the line or the background?

    – eyllanesc
    Mar 28 at 22:11











  • Forgot to mention that, the color of the line

    – Jan Novak
    Mar 28 at 22:33
















Do you want to change the color of the line or the background?

– eyllanesc
Mar 28 at 22:11





Do you want to change the color of the line or the background?

– eyllanesc
Mar 28 at 22:11













Forgot to mention that, the color of the line

– Jan Novak
Mar 28 at 22:33





Forgot to mention that, the color of the line

– Jan Novak
Mar 28 at 22:33












1 Answer
1






active

oldest

votes


















1


















If you want to change the color of the line you must set it with setColor():



from PySide2 import QtGui, QtWidgets
from PySide2.QtCharts import QtCharts

class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)

series = QtCharts.QLineSeries()
series.append(0,0)
series.append(1,7)
series.append(1.2,14)
series.append(1.3,21)
series.append(1.4,28)
series.append(1.5,35)

self.chartView = QtCharts.QChartView()
self.chartView.chart().addSeries(series)
self.chartView.chart().createDefaultAxes()
self.setCentralWidget(self.chartView)
series.setColor(QtGui.QColor("salmon"))

if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.resize(640, 480)
w.show()
sys.exit(app.exec_())


enter image description here



If you want to change the background color you must use the setCackgroundBrush() method of QChart():



self.chartView.chart().setBackgroundBrush(QtGui.QColor("gray"))


enter image description here






share|improve this answer


























  • Thank you so much again :)

    – Jan Novak
    Mar 28 at 22:33












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407585%2fhow-to-change-the-color-of-a-graph-in-pyside2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown


























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1


















If you want to change the color of the line you must set it with setColor():



from PySide2 import QtGui, QtWidgets
from PySide2.QtCharts import QtCharts

class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)

series = QtCharts.QLineSeries()
series.append(0,0)
series.append(1,7)
series.append(1.2,14)
series.append(1.3,21)
series.append(1.4,28)
series.append(1.5,35)

self.chartView = QtCharts.QChartView()
self.chartView.chart().addSeries(series)
self.chartView.chart().createDefaultAxes()
self.setCentralWidget(self.chartView)
series.setColor(QtGui.QColor("salmon"))

if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.resize(640, 480)
w.show()
sys.exit(app.exec_())


enter image description here



If you want to change the background color you must use the setCackgroundBrush() method of QChart():



self.chartView.chart().setBackgroundBrush(QtGui.QColor("gray"))


enter image description here






share|improve this answer


























  • Thank you so much again :)

    – Jan Novak
    Mar 28 at 22:33















1


















If you want to change the color of the line you must set it with setColor():



from PySide2 import QtGui, QtWidgets
from PySide2.QtCharts import QtCharts

class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)

series = QtCharts.QLineSeries()
series.append(0,0)
series.append(1,7)
series.append(1.2,14)
series.append(1.3,21)
series.append(1.4,28)
series.append(1.5,35)

self.chartView = QtCharts.QChartView()
self.chartView.chart().addSeries(series)
self.chartView.chart().createDefaultAxes()
self.setCentralWidget(self.chartView)
series.setColor(QtGui.QColor("salmon"))

if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.resize(640, 480)
w.show()
sys.exit(app.exec_())


enter image description here



If you want to change the background color you must use the setCackgroundBrush() method of QChart():



self.chartView.chart().setBackgroundBrush(QtGui.QColor("gray"))


enter image description here






share|improve this answer


























  • Thank you so much again :)

    – Jan Novak
    Mar 28 at 22:33













1














1










1









If you want to change the color of the line you must set it with setColor():



from PySide2 import QtGui, QtWidgets
from PySide2.QtCharts import QtCharts

class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)

series = QtCharts.QLineSeries()
series.append(0,0)
series.append(1,7)
series.append(1.2,14)
series.append(1.3,21)
series.append(1.4,28)
series.append(1.5,35)

self.chartView = QtCharts.QChartView()
self.chartView.chart().addSeries(series)
self.chartView.chart().createDefaultAxes()
self.setCentralWidget(self.chartView)
series.setColor(QtGui.QColor("salmon"))

if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.resize(640, 480)
w.show()
sys.exit(app.exec_())


enter image description here



If you want to change the background color you must use the setCackgroundBrush() method of QChart():



self.chartView.chart().setBackgroundBrush(QtGui.QColor("gray"))


enter image description here






share|improve this answer














If you want to change the color of the line you must set it with setColor():



from PySide2 import QtGui, QtWidgets
from PySide2.QtCharts import QtCharts

class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)

series = QtCharts.QLineSeries()
series.append(0,0)
series.append(1,7)
series.append(1.2,14)
series.append(1.3,21)
series.append(1.4,28)
series.append(1.5,35)

self.chartView = QtCharts.QChartView()
self.chartView.chart().addSeries(series)
self.chartView.chart().createDefaultAxes()
self.setCentralWidget(self.chartView)
series.setColor(QtGui.QColor("salmon"))

if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.resize(640, 480)
w.show()
sys.exit(app.exec_())


enter image description here



If you want to change the background color you must use the setCackgroundBrush() method of QChart():



self.chartView.chart().setBackgroundBrush(QtGui.QColor("gray"))


enter image description here







share|improve this answer













share|improve this answer




share|improve this answer










answered Mar 28 at 22:23









eyllanesceyllanesc

116k12 gold badges41 silver badges76 bronze badges




116k12 gold badges41 silver badges76 bronze badges















  • Thank you so much again :)

    – Jan Novak
    Mar 28 at 22:33

















  • Thank you so much again :)

    – Jan Novak
    Mar 28 at 22:33
















Thank you so much again :)

– Jan Novak
Mar 28 at 22:33





Thank you so much again :)

– Jan Novak
Mar 28 at 22:33


















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407585%2fhow-to-change-the-color-of-a-graph-in-pyside2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown









Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript