3D Histogram / bar chartSorting according to more than one key in pgfplotstable3d histogram without external...
Way of refund if scammed?
What Species of Trees are These?
Why is this python script running in background consuming 100 % CPU?
Why use nominative in Coniugatio periphrastica passiva?
why "American-born", not "America-born"?
Reverse Array, Let Elements in New Array Equal Length of Original Array Elements - JavaScript
Does science define life as "beginning at conception"?
What should I wear to go and sign an employment contract?
What quantum phenomena violate the superposition principle in electromagnetism?
How can sister protect herself from impulse purchases with a credit card?
Existence of a model of ZFC in which the natural numbers are really the natural numbers
3D Histogram / bar chart
How should I mix small caps with digits or symbols?
How did Jean Parisot de Valette, 49th Grand Master of the Order of Malta, die?
Why is there no current between two capacitors connected in series?
What does it mean for a program to be 32 or 64 bit?
How can I prevent Bash expansion from passing files starting with "-" as argument?
Good examples of "two is easy, three is hard" in computational sciences
Are there historical examples of audiences drawn to a work that was "so bad it's good"?
Buying a Mountain Bike from a friend
How to safely discharge oneself
Is it wise to pay off mortgage with 401k?
Managing heat dissipation in a magic wand
Warped chessboard
3D Histogram / bar chart
Sorting according to more than one key in pgfplotstable3d histogram without external programspgfplots using strings *from data table* as x axis labels in bar chartBar chart from CSV file with adjustable bar widthHow to draw a bar chart from multiple measurements with mean and varianceSegmented bar chart under tikz plotCombining line chart data with bar plotInsert space after each second barHow to plot histogram from a tab separated csv file containing tabular list of ordered tuples?Combine boxplot and histogram in one diagram (PGF/TikZ)pgfplots Histogram with Automatically Calculated Percentage BinsHistogram in pgfplots: Count the total number of data values
Hello fellows and folks!
I wanted to know if it is possible to plot a 3D histogram like these:
The file is a .csv one with 100K rows/tuples. My idea is to plot users (x-axis), movies(y-axis) and ratings (z-axis). For the first 10 rows or something like that.
Is it possible to draw?
This is how the structure of the file looks:
UserID, MovieID, Rating
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
bar-chart tikz-3dplot histogram
add a comment |
Hello fellows and folks!
I wanted to know if it is possible to plot a 3D histogram like these:
The file is a .csv one with 100K rows/tuples. My idea is to plot users (x-axis), movies(y-axis) and ratings (z-axis). For the first 10 rows or something like that.
Is it possible to draw?
This is how the structure of the file looks:
UserID, MovieID, Rating
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
bar-chart tikz-3dplot histogram
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
3 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
3 hours ago
add a comment |
Hello fellows and folks!
I wanted to know if it is possible to plot a 3D histogram like these:
The file is a .csv one with 100K rows/tuples. My idea is to plot users (x-axis), movies(y-axis) and ratings (z-axis). For the first 10 rows or something like that.
Is it possible to draw?
This is how the structure of the file looks:
UserID, MovieID, Rating
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
bar-chart tikz-3dplot histogram
Hello fellows and folks!
I wanted to know if it is possible to plot a 3D histogram like these:
The file is a .csv one with 100K rows/tuples. My idea is to plot users (x-axis), movies(y-axis) and ratings (z-axis). For the first 10 rows or something like that.
Is it possible to draw?
This is how the structure of the file looks:
UserID, MovieID, Rating
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
bar-chart tikz-3dplot histogram
bar-chart tikz-3dplot histogram
edited 2 hours ago
naveganteX
asked 3 hours ago
naveganteXnaveganteX
1977
1977
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
3 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
3 hours ago
add a comment |
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
3 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
3 hours ago
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
3 hours ago
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
3 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
3 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]{standalone}
usetikzlibrary{calc}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4{%
pgfkeysvalueof{/pgfplots/iflessthan/.@cmd}{#1}{#2}{#3}{#4}pgfeov
}%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8{%
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#1}{#4}{%
% first key <:
#7%
}{%
pgfplotsinvokeiflessthan{#4}{#1}{%
% first key >:
#8%
}{%
% first key ==:
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#2}{#5}{%
% second key <
#7%
}{%
pgfplotsinvokeiflessthan{#5}{#2}{%
% second key >
#8%
}{%
% second key ==
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#3}{#6}{%
% third key <
#7%
}{%
% third key >=
#8%
}%
}%
}%
}%
}%
}%
begin{document}
ifdefinedgconv
else
pgfmathsetmacro{gconv}{0.1}
fi
pgfplotstableread[col sep=comma,header=true]{%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
}{datatable}
%
%pgfplotstablesort[col sep=comma,header=true]resulttable{datatable}
pgfplotstablesort[create on use/sortkey/.style={
create col/assign/.code={%
edefentry{{thisrow{x}}{thisrow{y}}{thisrow{myvalue}}}%
pgfkeyslet{/pgfplots/table/create col/next content}entry
}
},
sort key=sortkey,
sort cmp={%
iflessthan/.code args={#1#2#3#4}{%
edeftemp{#1#2}%
expandafterpgfplotsmulticmpthreetempdo{#3}{#4}%
},
},
sort,
columns/Mtx/.style={string type},
columns/Kind/.style={string type},]resulttable{datatable}
begin{tikzpicture}%[x={(0.866cm,-0.5cm)},y={(0.866cm,0.5cm)},z={(0cm,1 cm)}]
pgfplotsset{set layers}
begin{axis}[% from section 4.6.4 of the pgfplotsmanual
view={120}{40},
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick={0,5,10},
zticklabels={0,2.5,5}, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style={grid=major},
ytick=data,
grid=minor,
xlabel={$x$},
ylabel={$y$},
zlabel={$z$},
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color={
draw=mapped color,fill=mapped color!70},
execute at begin plot={}
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{conv}{2*y1}
ifxgconvconv
else
xdefgconv{conv}
typeout{Pleasespace recompilespace thespace file!}
fi
};
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convx}{veclen(x1,y1)}
typeout{Onespace unitspace inspace xspace
directionspace isspaceconvx pt}
};
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convy}{veclen(x1,y1)}
typeout{Onespace unitspace inspace yspace
directionspace isspaceconvy pt}
};
addplot3 [visualization depends on={
gconv*z as myz}, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style={/pgfplots/cube/size z=myz},%
scatter/@pre marker code/.append style={/pgfplots/cube/size x=11.66135pt},%
scatter/@pre marker code/.append style={/pgfplots/cube/size y=9.10493pt},%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr={thisrow{x}},y expr={thisrow{y}},z
expr={1*thisrow{myvalue}},
meta expr={-1*thisrow{x}}
] resulttable;
end{axis}
makeatletter
immediatewrite@mainaux{xdefstringgconv{gconv}relax}
makeatother
end{tikzpicture}
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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/3.0/"u003ecc by-sa 3.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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f491565%2f3d-histogram-bar-chart%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
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]{standalone}
usetikzlibrary{calc}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4{%
pgfkeysvalueof{/pgfplots/iflessthan/.@cmd}{#1}{#2}{#3}{#4}pgfeov
}%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8{%
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#1}{#4}{%
% first key <:
#7%
}{%
pgfplotsinvokeiflessthan{#4}{#1}{%
% first key >:
#8%
}{%
% first key ==:
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#2}{#5}{%
% second key <
#7%
}{%
pgfplotsinvokeiflessthan{#5}{#2}{%
% second key >
#8%
}{%
% second key ==
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#3}{#6}{%
% third key <
#7%
}{%
% third key >=
#8%
}%
}%
}%
}%
}%
}%
begin{document}
ifdefinedgconv
else
pgfmathsetmacro{gconv}{0.1}
fi
pgfplotstableread[col sep=comma,header=true]{%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
}{datatable}
%
%pgfplotstablesort[col sep=comma,header=true]resulttable{datatable}
pgfplotstablesort[create on use/sortkey/.style={
create col/assign/.code={%
edefentry{{thisrow{x}}{thisrow{y}}{thisrow{myvalue}}}%
pgfkeyslet{/pgfplots/table/create col/next content}entry
}
},
sort key=sortkey,
sort cmp={%
iflessthan/.code args={#1#2#3#4}{%
edeftemp{#1#2}%
expandafterpgfplotsmulticmpthreetempdo{#3}{#4}%
},
},
sort,
columns/Mtx/.style={string type},
columns/Kind/.style={string type},]resulttable{datatable}
begin{tikzpicture}%[x={(0.866cm,-0.5cm)},y={(0.866cm,0.5cm)},z={(0cm,1 cm)}]
pgfplotsset{set layers}
begin{axis}[% from section 4.6.4 of the pgfplotsmanual
view={120}{40},
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick={0,5,10},
zticklabels={0,2.5,5}, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style={grid=major},
ytick=data,
grid=minor,
xlabel={$x$},
ylabel={$y$},
zlabel={$z$},
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color={
draw=mapped color,fill=mapped color!70},
execute at begin plot={}
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{conv}{2*y1}
ifxgconvconv
else
xdefgconv{conv}
typeout{Pleasespace recompilespace thespace file!}
fi
};
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convx}{veclen(x1,y1)}
typeout{Onespace unitspace inspace xspace
directionspace isspaceconvx pt}
};
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convy}{veclen(x1,y1)}
typeout{Onespace unitspace inspace yspace
directionspace isspaceconvy pt}
};
addplot3 [visualization depends on={
gconv*z as myz}, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style={/pgfplots/cube/size z=myz},%
scatter/@pre marker code/.append style={/pgfplots/cube/size x=11.66135pt},%
scatter/@pre marker code/.append style={/pgfplots/cube/size y=9.10493pt},%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr={thisrow{x}},y expr={thisrow{y}},z
expr={1*thisrow{myvalue}},
meta expr={-1*thisrow{x}}
] resulttable;
end{axis}
makeatletter
immediatewrite@mainaux{xdefstringgconv{gconv}relax}
makeatother
end{tikzpicture}
end{document}
add a comment |
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]{standalone}
usetikzlibrary{calc}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4{%
pgfkeysvalueof{/pgfplots/iflessthan/.@cmd}{#1}{#2}{#3}{#4}pgfeov
}%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8{%
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#1}{#4}{%
% first key <:
#7%
}{%
pgfplotsinvokeiflessthan{#4}{#1}{%
% first key >:
#8%
}{%
% first key ==:
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#2}{#5}{%
% second key <
#7%
}{%
pgfplotsinvokeiflessthan{#5}{#2}{%
% second key >
#8%
}{%
% second key ==
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#3}{#6}{%
% third key <
#7%
}{%
% third key >=
#8%
}%
}%
}%
}%
}%
}%
begin{document}
ifdefinedgconv
else
pgfmathsetmacro{gconv}{0.1}
fi
pgfplotstableread[col sep=comma,header=true]{%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
}{datatable}
%
%pgfplotstablesort[col sep=comma,header=true]resulttable{datatable}
pgfplotstablesort[create on use/sortkey/.style={
create col/assign/.code={%
edefentry{{thisrow{x}}{thisrow{y}}{thisrow{myvalue}}}%
pgfkeyslet{/pgfplots/table/create col/next content}entry
}
},
sort key=sortkey,
sort cmp={%
iflessthan/.code args={#1#2#3#4}{%
edeftemp{#1#2}%
expandafterpgfplotsmulticmpthreetempdo{#3}{#4}%
},
},
sort,
columns/Mtx/.style={string type},
columns/Kind/.style={string type},]resulttable{datatable}
begin{tikzpicture}%[x={(0.866cm,-0.5cm)},y={(0.866cm,0.5cm)},z={(0cm,1 cm)}]
pgfplotsset{set layers}
begin{axis}[% from section 4.6.4 of the pgfplotsmanual
view={120}{40},
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick={0,5,10},
zticklabels={0,2.5,5}, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style={grid=major},
ytick=data,
grid=minor,
xlabel={$x$},
ylabel={$y$},
zlabel={$z$},
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color={
draw=mapped color,fill=mapped color!70},
execute at begin plot={}
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{conv}{2*y1}
ifxgconvconv
else
xdefgconv{conv}
typeout{Pleasespace recompilespace thespace file!}
fi
};
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convx}{veclen(x1,y1)}
typeout{Onespace unitspace inspace xspace
directionspace isspaceconvx pt}
};
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convy}{veclen(x1,y1)}
typeout{Onespace unitspace inspace yspace
directionspace isspaceconvy pt}
};
addplot3 [visualization depends on={
gconv*z as myz}, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style={/pgfplots/cube/size z=myz},%
scatter/@pre marker code/.append style={/pgfplots/cube/size x=11.66135pt},%
scatter/@pre marker code/.append style={/pgfplots/cube/size y=9.10493pt},%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr={thisrow{x}},y expr={thisrow{y}},z
expr={1*thisrow{myvalue}},
meta expr={-1*thisrow{x}}
] resulttable;
end{axis}
makeatletter
immediatewrite@mainaux{xdefstringgconv{gconv}relax}
makeatother
end{tikzpicture}
end{document}
add a comment |
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]{standalone}
usetikzlibrary{calc}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4{%
pgfkeysvalueof{/pgfplots/iflessthan/.@cmd}{#1}{#2}{#3}{#4}pgfeov
}%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8{%
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#1}{#4}{%
% first key <:
#7%
}{%
pgfplotsinvokeiflessthan{#4}{#1}{%
% first key >:
#8%
}{%
% first key ==:
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#2}{#5}{%
% second key <
#7%
}{%
pgfplotsinvokeiflessthan{#5}{#2}{%
% second key >
#8%
}{%
% second key ==
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#3}{#6}{%
% third key <
#7%
}{%
% third key >=
#8%
}%
}%
}%
}%
}%
}%
begin{document}
ifdefinedgconv
else
pgfmathsetmacro{gconv}{0.1}
fi
pgfplotstableread[col sep=comma,header=true]{%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
}{datatable}
%
%pgfplotstablesort[col sep=comma,header=true]resulttable{datatable}
pgfplotstablesort[create on use/sortkey/.style={
create col/assign/.code={%
edefentry{{thisrow{x}}{thisrow{y}}{thisrow{myvalue}}}%
pgfkeyslet{/pgfplots/table/create col/next content}entry
}
},
sort key=sortkey,
sort cmp={%
iflessthan/.code args={#1#2#3#4}{%
edeftemp{#1#2}%
expandafterpgfplotsmulticmpthreetempdo{#3}{#4}%
},
},
sort,
columns/Mtx/.style={string type},
columns/Kind/.style={string type},]resulttable{datatable}
begin{tikzpicture}%[x={(0.866cm,-0.5cm)},y={(0.866cm,0.5cm)},z={(0cm,1 cm)}]
pgfplotsset{set layers}
begin{axis}[% from section 4.6.4 of the pgfplotsmanual
view={120}{40},
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick={0,5,10},
zticklabels={0,2.5,5}, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style={grid=major},
ytick=data,
grid=minor,
xlabel={$x$},
ylabel={$y$},
zlabel={$z$},
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color={
draw=mapped color,fill=mapped color!70},
execute at begin plot={}
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{conv}{2*y1}
ifxgconvconv
else
xdefgconv{conv}
typeout{Pleasespace recompilespace thespace file!}
fi
};
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convx}{veclen(x1,y1)}
typeout{Onespace unitspace inspace xspace
directionspace isspaceconvx pt}
};
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convy}{veclen(x1,y1)}
typeout{Onespace unitspace inspace yspace
directionspace isspaceconvy pt}
};
addplot3 [visualization depends on={
gconv*z as myz}, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style={/pgfplots/cube/size z=myz},%
scatter/@pre marker code/.append style={/pgfplots/cube/size x=11.66135pt},%
scatter/@pre marker code/.append style={/pgfplots/cube/size y=9.10493pt},%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr={thisrow{x}},y expr={thisrow{y}},z
expr={1*thisrow{myvalue}},
meta expr={-1*thisrow{x}}
] resulttable;
end{axis}
makeatletter
immediatewrite@mainaux{xdefstringgconv{gconv}relax}
makeatother
end{tikzpicture}
end{document}
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]{standalone}
usetikzlibrary{calc}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotsset{compat=1.16}
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4{%
pgfkeysvalueof{/pgfplots/iflessthan/.@cmd}{#1}{#2}{#3}{#4}pgfeov
}%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8{%
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#1}{#4}{%
% first key <:
#7%
}{%
pgfplotsinvokeiflessthan{#4}{#1}{%
% first key >:
#8%
}{%
% first key ==:
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#2}{#5}{%
% second key <
#7%
}{%
pgfplotsinvokeiflessthan{#5}{#2}{%
% second key >
#8%
}{%
% second key ==
pgfplotsset{float <}%
pgfplotsinvokeiflessthan{#3}{#6}{%
% third key <
#7%
}{%
% third key >=
#8%
}%
}%
}%
}%
}%
}%
begin{document}
ifdefinedgconv
else
pgfmathsetmacro{gconv}{0.1}
fi
pgfplotstableread[col sep=comma,header=true]{%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
}{datatable}
%
%pgfplotstablesort[col sep=comma,header=true]resulttable{datatable}
pgfplotstablesort[create on use/sortkey/.style={
create col/assign/.code={%
edefentry{{thisrow{x}}{thisrow{y}}{thisrow{myvalue}}}%
pgfkeyslet{/pgfplots/table/create col/next content}entry
}
},
sort key=sortkey,
sort cmp={%
iflessthan/.code args={#1#2#3#4}{%
edeftemp{#1#2}%
expandafterpgfplotsmulticmpthreetempdo{#3}{#4}%
},
},
sort,
columns/Mtx/.style={string type},
columns/Kind/.style={string type},]resulttable{datatable}
begin{tikzpicture}%[x={(0.866cm,-0.5cm)},y={(0.866cm,0.5cm)},z={(0cm,1 cm)}]
pgfplotsset{set layers}
begin{axis}[% from section 4.6.4 of the pgfplotsmanual
view={120}{40},
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick={0,5,10},
zticklabels={0,2.5,5}, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style={grid=major},
ytick=data,
grid=minor,
xlabel={$x$},
ylabel={$y$},
zlabel={$z$},
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color={
draw=mapped color,fill=mapped color!70},
execute at begin plot={}
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{conv}{2*y1}
ifxgconvconv
else
xdefgconv{conv}
typeout{Pleasespace recompilespace thespace file!}
fi
};
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convx}{veclen(x1,y1)}
typeout{Onespace unitspace inspace xspace
directionspace isspaceconvx pt}
};
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextra{pgfmathsetmacro{convy}{veclen(x1,y1)}
typeout{Onespace unitspace inspace yspace
directionspace isspaceconvy pt}
};
addplot3 [visualization depends on={
gconv*z as myz}, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style={/pgfplots/cube/size z=myz},%
scatter/@pre marker code/.append style={/pgfplots/cube/size x=11.66135pt},%
scatter/@pre marker code/.append style={/pgfplots/cube/size y=9.10493pt},%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr={thisrow{x}},y expr={thisrow{y}},z
expr={1*thisrow{myvalue}},
meta expr={-1*thisrow{x}}
] resulttable;
end{axis}
makeatletter
immediatewrite@mainaux{xdefstringgconv{gconv}relax}
makeatother
end{tikzpicture}
end{document}
answered 2 hours ago
marmotmarmot
128k6162308
128k6162308
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f491565%2f3d-histogram-bar-chart%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
3 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
3 hours ago